Skip to content

Instantly share code, notes, and snippets.

#requires -modules "PnP.PowerShell"
Connect-PnPOnline `
-Url "https://$env:O365_TENANT-admin.sharepoint.com" `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
-Tenant $env:O365_TENANTID `
-ErrorAction Stop
$unifiedGroups = Get-PnPMicrosoft365Group
@joerodgers
joerodgers / Find-OrphanedM365Groups.ps1
Last active June 21, 2024 15:36
Shows all M365 group connected sites and reports if the associated M365 group exists.
#requires -module "PnP.PowerShell"
# Required permissions:
# Microsoft Graph API : One of Directory.Read.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, GroupMember.Read.All, GroupMember.ReadWrite.All
# SharePoint Online : Sites.FullControl.All
Connect-PnPOnline `
-Url "https://$env:O365_TENANT-admin.sharepoint.com" `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
-Tenant $env:O365_TENANTID `
@joerodgers
joerodgers / Get-SharePointSiteGroupMembers.ps1
Created June 21, 2024 15:04
Reports the memberships of the Owners, Members, and Visitors groups of SharePoint Online sites. This example further filters the results to only show sites with any group containing the EEEU claim
function Get-SiteId
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[System.Uri]
$SiteUrl
)
#requires -modules "Microsoft.Xrm.Data.Powershell"
$ErrorActionPreference = [System.Management.Automation.ActionPreference]::Stop
$credential = [PSCredential]::new( 'powerplatfromadmin@contoso.com', ( '<password>' | ConvertTo-SecureString -AsPlainText -Force) )
$environments = Get-CrmOrganizations -OnLineType Office365 -Credential $credential
$timestamp = Get-Date -Format FileDateTime
@joerodgers
joerodgers / Get-LoopWorkspaceData.ps1
Created June 4, 2024 20:44
Exports Loop Workspace Data to CSV
Connect-SPOService -Url "https://contoso-admin.sharepoint.com"
$counter = 1
$token = $null
$containers = do
{
Write-Host "[$(Get-Date)] - Fetching Containers page: $counter"
$containers = if( -not $token )
@joerodgers
joerodgers / Add-SiteUrlToSharePointSiteUsageDetailReport.ps1
Created June 3, 2024 15:08
Fills in the missing Site Url column value in the SharePointSiteUsageDetail report.
#requires -module "PnP.PowerShell"
# SharePoint > Application > Sites.FullControl.All
Connect-PnPOnline `
-Url "https://$env:O365_TENANT-admin.sharepoint.com" `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
-Tenant $env:O365_TENANTID `
-ErrorAction Stop
@joerodgers
joerodgers / Disable-TeamifyDialog.ps1
Created June 3, 2024 14:48
Example script to hide the "Teamify" Dialog box on all M365 group connected sites
#requires -modules "PnP.PowerShell"
# permission requirements
# - Microsoft Graph > Application > one of Directory.Read.All, Directory.ReadWrite.All, Group.Read.All, Group.ReadWrite.All, GroupMember.Read.All, GroupMember.ReadWrite.All
# - SharePoint > Application > Sites.FullControl.All
Connect-PnPOnline `
-Url "https://$env:O365_TENANT-admin.sharepoint.com" `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
#requires -modules "AzureAD"
Connect-AzureAD
$clientId = 'aa326a3b-706a-4a7c-a96f-1a7e371e967x'
$endDate = [DateTime]::Today.AddYears(2)
$startDate = [Datetime]::Today
$app = Get-AzureADServicePrincipal -Filter "AppId eq '$clientId'"
@joerodgers
joerodgers / Get-FolderChildCount.ps1
Created May 17, 2024 19:23
Gets the file and folder count for the provided list folder and, optionally, all sub folders.
#requies -modules "PnP.PowerShell"
function Get-FolderChildCount
{
[CmdletBinding()]
param
(
[Parameter(Mandatory=$true)]
[Microsoft.SharePoint.Client.List]
$List,
#requires -modules "PnP.PowerShell"
# permissions required SharePoint > Application > Sites.FullControl.All
Connect-PnPOnline `
-Url "https://$env:O365_TENANT-admin.sharepoint.com" `
-ClientId $env:O365_CLIENTID `
-Thumbprint $env:O365_THUMBPRINT `
-Tenant $env:O365_TENANT `
-ErrorAction Stop