Skip to content

Instantly share code, notes, and snippets.

python3 alert-step1-server.py
//https://yuml.me/diagram/scruffy/class/draw
[Alert Rule]*-*[Action Group]
# Prerequisites
# AllowBasic as Admin, perhaps in a separate window
# Set-ItemProperty -path 'HKLM:\\SOFTWARE\\Policies\\Microsoft\\Windows\\WinRM\\Client' -Name AllowBasic -Value 1
# Connect to Exchange Online
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
# you can get $groupId from the SPO object
$exogroup = Get-UnifiedGroup -Identity $groupId
# This is just an example for time estimations in write-progress,
# though a simplified scenario
$sitesBareMinimum = Get-SPOSite -Limit All
$starttime = Get-Date
$count = 0 # kind of an index, counter
$total = $sitesBareMinimum.Count
$sites = $sitesBareMinimum | ForEach-Object {
$site = $_
$estimation = ""
$now = Get-Date
# do you want to check something in a mssql database and don't have sql server management studio, then powershell is your best friend
# best parts from that blog post: https://www.sqlshack.com/connecting-powershell-to-sql-server/
$sqlConn = New-Object System.Data.SqlClient.SqlConnection
$sqlConn.ConnectionString = "data source=servername;initial catalog=<database_name>;Integrated Security=SSPI;MultipleActiveResultSets=True;App=EntityFramework"
$sqlcmd = $sqlConn.CreateCommand()
$sqlcmd.Connection = $sqlConn
$query = "SELECT name, database_id FROM sys.databases"
$sqlcmd.CommandText = $query
#bonus: convert array to a hash table
$users | ForEach-Object {
$usersHash.Add($_.UserPrincipalName, $_)
}
$tenant = "takana17"
Connect-PnPOnline https://$tenant.sharepoint.com/ -SPOManagementShell -ClearTokenCache
$realm = Get-PnPAuthenticationRealm
$loginName = "c:0-.f|rolemanager|spo-grid-all-users/$realm"
$group = Get-PnPGroup -AssociatedVisitorGroup
Add-PnPUserToGroup -LoginName $loginName -Identity $group
az storage blob upload-batch \
--source $(sourceFolder)/bundledFiles \
--destination $(storageContainer)/$(toolPath) \
--account-name $(storageAccount)
# Install nvm-setup.zip: https://github.com/coreybutler/nvm-windows/releases
nvm install 12.6.3
nvm use 12.6.3
npm i -g @pnp/office365-cli
# install git
#SPO
Install-Module Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
# https://docs.microsoft.com/en-us/power-platform/admin/powerapps-powershell
install-module -Name Microsoft.PowerApps.Administration.PowerShell -Scope CurrentUser
Install-Module -Name Microsoft.PowerApps.PowerShell -Scope CurrentUser -AllowClobber
Add-PowerAppsAccount # logs you in with MFA and is valid for 8 hours
Get-Flow # list all my flows
Get-PowerApp # list all my powerapps
Get-AdminPowerAppEnvironment -Default
Get-AdminPowerAppEnvironment
get-powerapp -EnvironmentName "f2c25912-5da2-4da1-9486-afa625981863"
Set-AdminPowerAppOwner `