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.

  1. Go to the SharePoint admin center by typing URL https://<your tenant>-admin.sharepoint.com
  2. Select Sites -> Active Sites
  3. Go to Template
  4. Select Filter by Template
  5. Select Communication Site
Retrieve all Communication Sites using PnP PowerShell
Retrieve all Communication Sites using PowerShell

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

PowerShell to get all Communication sites from SharePoint Online

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.

7 thoughts on “Retrieve all Communication Sites using PnP PowerShell”
  1. I am the proprietor of JustCBD company (justcbdstore.com) and I’m presently planning to grow my wholesale side of business. It would be great if someone at targetdomain share some guidance . I thought that the very best way to do this would be to reach out to vape companies and cbd stores. I was hoping if anybody at all could recommend a trustworthy web site where I can buy CBD Shops B2B Leads I am presently examining creativebeartech.com, theeliquidboutique.co.uk and wowitloveithaveit.com. On the fence which one would be the very best selection and would appreciate any assistance on this. Or would it be easier for me to scrape my own leads? Ideas?

Leave a Reply