Skip to content

Instantly share code, notes, and snippets.

Avatar

Anatoly Mironov mirontoli

View GitHub Profile
View remove-live-photo-videos.sh
find . -type f -name "*.JPG" | \
while read -r f;do [ -e "${f%.JPG}.MOV" ] && rm "${f%.JPG}.MOV";done
View alert-actiongroup-relationship.uml
//https://yuml.me/diagram/scruffy/class/draw
[Alert Rule]*-*[Action Group]
View determine-yammer-group.ps1
# 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
View estimated-progress.ps1
# 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
View read-sql.ps1
# 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
View optimize-lookup-convert.ps1
#bonus: convert array to a hash table
$users | ForEach-Object {
$usersHash.Add($_.UserPrincipalName, $_)
}
View grant-perms.ps1
$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
View azure-cli.sh
az storage blob upload-batch \
--source $(sourceFolder)/bundledFiles \
--destination $(storageContainer)/$(toolPath) \
--account-name $(storageAccount)
View office365-modules.ps1
# 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
#PnP
You can’t perform that action at this time.