Hello SharePointers,
During my latest development, my client asked me to get all Communication Sites using PnP PowerShell.
For Example, Communication Sites, Hub Sites, Classic team site, and Modern team site.
From UI we can just filter the site type and get it done, but listing down all sites is a very time-consuming task.
Get all Communication sites from Tenant.
To Do this from UI, you can just follow below steps.
- Go to the SharePoint admin center by typing URL
https://<your tenant>-admin.sharepoint.com
- Select Sites -> Active Sites
- Go to Template
- Select Filter by Template
- Select Communication Site
In this way, we can get all communication sites from SharePoint Online manually from UI. Now let us see the same results using SPO PowerShell
Now we are going write a PowerShell script to retrieve all communication sites from PowerShell.
Psudocode
Step 1. Connect to SharePoint Admin Site
Step 2. Get All communication site.
Script:
And here is a script to retrieve all Communication sites from SharePoint Online tenant.
PnP PowerShell to find all Communication sites
Below are the PnP commandlets used to find all communication sites from tenant.
$AdminSite = "https://sharePointgems-admin.sharepoint.com"
#Connect SharePoint Admin Site
Connect-PnPOnline -url $AdminSite -UseWebLogin
#Retrieve All Communication Sites
Get-PnPTenantSite -Template SITEPAGEPUBLISHING#0
Retrieve All Communication Sites using SPO PowerShell
In a similar way as PnP PowerShell, we can fin all communication sites using SharePoint Management Shell as well. Below is the code for the same.
$AdminSite = "https://sharePointgems-admin.sharepoint.com"
#Connect SharePoint Admin Site
Connect-SPOService -url $AdminSite -Credential (Get-Credential)
#Retrieve All Communication Sites
Get-SPOSite -Template SITEPAGEPUBLISHING#0 -Limit ALL
This script results will list down all communication sites based on template type called “SITEPAGEPUBLISHING#0”.
how to get all subsites in sharepoint using powershell, pnp powershell get site owners, get site template sharepoint online powershell get all site collection administrators powershell get-pnptenantsite 403 forbidden
pnp community get-pnpweb example pnp powershell get site owners
pnp sites get-pnptenantsite : value cannot be null. new-pnpsite pnp powershell.
Like!! Thank you for publishing this awesome article.
I like the valuable information you provide in your articles.
bookmarked!!, I like your blog!