Skip to content

Instantly share code, notes, and snippets.

View o365-license-storage.ps1
# it calculates storage capacity in SharePoint Online
# read more on my blog post: https://chuvash.eu/?p=5360
$sku = Get-MsolAccountSku
$sku2 = $sku | % {
$s = $_;
$sr = [PSCustomObject]@{
SkuPartNumber = $s.SkuPartNumber;
Licenses = $s.ActiveUnits + $s.WarningUnits
Services = $s.ServiceStatus | % { $_.ServicePlan.ServiceName };
};
View azure-devops-release-finalize-git.sh
git config --global user.email "azuredevops@microsoft.com"
git config --global user.name "Azure DevOps"
REPO="$(System.TeamFoundationCollectionUri)$(System.TeamProject)/_git/$(Build.Repository.Name)"
EXTRAHEADER="Authorization: Bearer $(System.AccessToken)"
git -c http.extraheader="$EXTRAHEADER" clone $REPO
cd $(Build.Repository.Name)
MAINBRANCHNAME=$(git rev-parse --abbrev-ref HEAD)
View demote-news.ps1
$site = "https://{tenant}.sharepoint.com/sites/{site}"
Connect-PnPOnline -Url $site -SPOManagementShell -ClearTokenCache
$field = "Promoted State"
$list = "Site Pages"
$id = 85 #the item id of the news
Set-PnPField -Identity $field -List $list -Values @{ReadOnlyField=$false}
#make sure to enclose the number into quotation marks
Set-PnPListItem -List $list -Identity $id -Values {"Promoted State"="0"}
#reset the field
Set-PnPField -Identity $field -List $list -Values @{ReadOnlyField=$true}
View get-services-health-admin.js
//this little javascript is to get the services to include in the
//Microsoft 365 Admin Center -> Health Center -> Preferences
//Inspect the area in Chrome/Edge and then run this in Console
spans = $0.querySelectorAll('div > div span')
arr2 = Array.prototype.slice.call(spans)
arr2.map(s => s.innerText).join('\n')
View magicmirror.config.js
var config = {
address: "0.0.0.0", // Address to listen on, can be:
port: 8080,
basePath: "/", // The URL path where MagicMirror is hosted. If you are using a Reverse proxy
ipWhitelist: [], // Set [] to allow all IP addresses
useHttps: false, // Support HTTPS or not, default "false" will use HTTP
httpsPrivateKey: "", // HTTPS private key path, only require when useHttps is true
httpsCertificate: "", // HTTPS Certificate path, only require when useHttps is true
language: "cv",
logLevel: ["INFO", "LOG", "WARN", "ERROR"],
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