Skip to content

Instantly share code, notes, and snippets.


Anatoly Mironov mirontoli

View GitHub Profile
find . -type f -name "*.JPG" | \
while read -r f;do [ -e "${f%.JPG}.MOV" ] && rm "${f%.JPG}.MOV";done
View alert-actiongroup-relationship.uml
[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
# 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:
$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://$ -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)
View office365-modules.ps1
# Install
nvm install 12.6.3
nvm use 12.6.3
npm i -g @pnp/office365-cli
# install git
Install-Module Microsoft.Online.SharePoint.PowerShell -Scope CurrentUser
You can’t perform that action at this time.