Disclaimer: This post is written based on the current functionality being rolled out, and might not be applicable in the future as the functionality evolves.
….is currently Communication Sites.
Read on if you feel like it :)
My musings on Office 365, search, programming and technology.
(June 1st, 2019, I started as a full time employee of Microsoft, thus any post before that date are solely written on my own behalf)
Disclaimer: This post is written based on the current functionality being rolled out, and might not be applicable in the future as the functionality evolves.
….is currently Communication Sites.
Read on if you feel like it :)
# Connect to admin site Connect-PnPOnline https://contoso-admin.sharepoint.com # Enable external sharing. Possible values are: # ExistingExternalUserSharingOnly # ExternalUserAndGuestSharing # ExternalUserSharingOnly # Disabled Set-PnPTenantSite -Url https://contoso.sharepoint.com/teams/Communication201 -Sharing ExternalUserSharingOnly
# Connect to admin site Connect-SPOService -Url https://contoso-admin.sharepoint.com Set-SPOSite -Identity https://contoso.sharepoint.com/teams/Communication201 -SharingCapability ExternalUserAndGuestSharing
The unique identifier for a Communication site is the web template used, and the name of the template for Communication sites is SITEPAGEPUBLISHING.
With this piece of information there are a couple of options you can use to find all the sites.
The first is to iterate over all site collections, and filter on the web template property, the other is to use search.
To list all sites you can use the SPO Management Shell, CSOM tenant API, or hope my PR at PnP PowerShell get’s accepted (https://github.com/SharePoint/PnP-PowerShell/pull/998)
Basically the CSOM code looks something like this:
SPOSitePropertiesEnumerableFilter filter = new SPOSitePropertiesEnumerableFilter() { IncludePersonalSite = PersonalSiteFilter.UseServerDefault, StartIndex = null, IncludeDetail = true, Template = "SITEPAGEPUBLISHING#0", Filter = null }; var list = Tenant.GetSitePropertiesFromSharePointByFilters(filter);
Using the SharePoint Online Management Shell do this:
Connect-SPOService https://contoso-admin.sharepoint.com Get-SPOSite -Template SITEPAGEPUBLISHING#0 -Limit ALL
With the PR accepted you would be able to use PnP Posh with the following command to list all Communication sites much like the management shell:
Connect-PnPOnline https://contoso-admin.sharepoint.com Get-PnPTenantSite -WebTemplate SITEPAGEPUBLISHING#0
If you want to use search, you can use the Submit-PnPSearchQuery commandlet.
Submit-PnPSearchQuery -Query "webtemplate=SITEPAGEPUBLISHING" -All -RelevantResultsThis approach is of course available for other templates as well. Happy iteration!