For now a
days, we are
keep on talking about modern team and
communication sites. Here I’m going to list out the commands to get the details
on the modern sites created based on the team and communication templates.
Visit SharePoint/PnPPowerShell from Github to
know more about PnP Powershell and you can view all the powershell cmdlets from PnPPowershell Documentation
In this post,
I’m giving you an example based on SharePoint online. So I have installed the
online module called “SharePointPnPPowerShellOnline”.
Before
accessing the SharePoint objects, open the powershell command
prompt and ensure latest
powershell module installed on your machine.
Use the below command
to update to the latest
SharePointPnPPowerShellOnline module,
PS: >
Update-Module SharePointPnPPowerShell*
Use the below
command references to connect the SharePoint online site
PS: >
$credential = Get-credential
PS: >
Connect-PnPOnline -Url https://ktskumar.sharepoint.com -Credential $credential
Once we got
connected to the SharePoint site, use the below commands to get the list of
available sites in SharePoint tenant.
Get all SharePoint sites except Modern sites
PS: >
Get-PnPTenantSite
The above PnP powershell command
retrieves and shows the available SharePoint classic sites in the Tenant.
It doesn’t returns the sites created with modern templates. We may expect this
command to show classic and modern sites in coming
days .
Get all SharePoint sites
including modern and onedrive sites
PS: >
Get-PnPTenantSite - IncludeOneDriveSites
The above PnP
command retrieves and shows the classic, modern and OneDrive for Buisness sites
from the Tenant.
Get all Modern Team SharePoint sites
PS: >
Get-PnPTenantSite -WebTemplate GROUP#0
The above PnP powershell command
gets and lists the sites created based on Modern team site template from the
SharePoint tenant. And each site is associated with a Office
365 group.
Get all Modern Communication SharePoint sites
PS: >
Get-PnPTenantSite -WebTemplate SITEPAGEPUBLISHING#0
The above PnP powershell command
lists the communication sites from the SharePoint tenant.
The SharePoint
online site collection information are
stored in the hidden list called
“DO_NOT_DELETE_SPLIST_TENANTADMIN_AGGREGATED_SITECOLLECTIONS” under SharePoint
Tenant Administration site and this list has the below columns
Classification
|
||
Title
|
By using the
this list, we can also categorize and retrieve the modern site
collections. Use the below command references to connect the
SharePoint Tenant Administration online site
PS: >
$credential = Get-credential
PS: >
Connect-PnPOnline -Url https://ktskumar-admin.sharepoint.com -Credential
$credential