Iterate through root site and subsites libraries #3186
-
I am trying to loop through libraries in sub sites and main site. The below script only getting the libraries from main site only. $SiteURL = "YourSite" #Connect to PnP Online #Get all subsites in a SharePoint Online site foreach ($Site in $Subsites) I'd appreciate some help. Seems I am missing something here. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 4 replies
-
You should get all subwebs as long as you specify -Recurse Maybe you dont have access to the subsites? The code works as intended for me, but i noticed a small typo though in your where filter: it needs to be $.BaseType and $.Hidden ($_ is an alias for $PSItem ) |
Beta Was this translation helpful? Give feedback.
Ah yes good point!
The Get-PnPList in the loop need to know that you are pointing to a new subweb!
You do this by connecting to the subweb inside the loop. Try something like this: