Forum Discussion
Nigel_Price9911
Apr 23, 2017Iron Contributor
Iterating Through Site Collections in a Tenancy using PnP PowerShell
Does anyone know how I can Iterate through a series of Site Collections in a Office 365 tenancy using PnP PowerShell ? I can get a series of Site Collections using :- $SiteCollections = Get-P...
- Apr 24, 2017
Hi Nigel_Price9911,
I would go for something like this to list all subwebs for each site collection:
$cred = Get-Credential Connect-PnPOnline "https://mytenant.sharepoint.com" -Credentials $cred $SiteCollections = Get-PnPTenantSite foreach ($SiteCollection in $SiteCollections) { Connect-PnPOnline -Url $SiteCollection.Url -Credentials $cred Get-PnPSubWebs }
Apr 24, 2017
Hi Nigel_Price9911,
I would go for something like this to list all subwebs for each site collection:
$cred = Get-Credential Connect-PnPOnline "https://mytenant.sharepoint.com" -Credentials $cred $SiteCollections = Get-PnPTenantSite foreach ($SiteCollection in $SiteCollections) { Connect-PnPOnline -Url $SiteCollection.Url -Credentials $cred Get-PnPSubWebs }
Nigel_Price9911
Apr 24, 2017Iron Contributor
Thanks Pieter Veenstra that will do nicely.