SharePoint Online: Find All Communication Sites using PowerShell
Requirement: Get All Communication Sites in SharePoint Online Tenant
How to Find All Communication Site Collections in SharePoint Online?
Communication sites are used to broadcast a message, such as news, reports, etc., to your organization in a visually compelling way. E.g., Intranet site. If you want to get a list of communication sites in SharePoint Online, do the following:
- Login to SharePoint admin center (At https://tenant-admin.sharepoint.com)
- Click on Sites >> Active Sites. This gets you all sites in the tenant. Now you can filter sites based on a specific site template, E.g. “Communication Sites”.
SharePoint Online: PowerShell to Get All Communication Sites
Communication sites in SharePoint Online tenant can be quickly listed by filtering sites based on the web template ID “SITEPAGEPUBLISHING#0”.
#Parameters
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
#Connect to Tenant Admin Site
Connect-SPOService -url $TenantAdminURL -Credential (Get-Credential)
#Get All Communication Sites
Get-SPOSite -Template SITEPAGEPUBLISHING#0 -Limit ALL
This script lists every modern communication site in the tenant.
Let’s add a site collection administrator to all communication sites in the tenant.
#Parameters
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
$AdminID = "[email protected]"
#Connect to Admin Center
Connect-SPOService -Url $TenantAdminURL -Credential (Get-credential)
#Get All Communication Sites
Get-SPOSite -Template SITEPAGEPUBLISHING#0 | ForEach-Object {
#Add Site Collection Admin
Set-SPOUser -Site $_.Url -LoginName $AdminID -IsSiteCollectionAdmin $True | Out-Null
Write-host -f Green "Added Site collection Administrator to site:"$_.URL
}
PnP PowerShell to Find All Communication Site collections
Similar to the above SharePoint Online Management Shell, The PnP cmdlets also can be used to list all Communication sites:
#Parameters
$TenantAdminURL = "https://crescent-admin.sharepoint.com"
#Connect to Tenant Admin Site
Connect-PnPOnline -url $TenantAdminURL -Interactive
#Get All Communication Sites
Get-PnPTenantSite -Template "SITEPAGEPUBLISHING#0"