Apr 23 2017 03:33 PM - edited Apr 23 2017 03:34 PM
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-PnPTenantSite
Now I want to iterate through $SIteCollections printing out the title and URL.
Apr 23 2017 03:51 PM
you can do something like
$sites = Get-SPOSite -Limit all -Detailed | Out-GridView -Title "Select site collections " -PassThru;
foreach($site in $sites)
{ do stuff
}
Apr 24 2017 12:17 AM
Hi Dean
Does this work with PnP PowerShell or does this work with CSOM only ?
Regards
Nigel
Apr 24 2017 02:08 AM
SolutionHi @Nigel Price,
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 02:27 AM
Thanks @Pieter Veenstra that will do nicely.
Dec 30 2018 08:42 PM
@Pieter Veenstra Is there a way to iterate all subwebs of a subweb using PNP? My foreach loop is not going deeper than the initial subweb.
What's up @Dean Gross!
Dec 30 2018 08:52 PM