Forum Discussion
Nigel Price
May 18, 2017Iron Contributor
getting all lists within a subweb
Hi I am trying to get all of the lists within a subweb :- Get-PnPLists -Web Https://sometenant.sharepoint.com/sites/this-site This keeps returning a FileNotFound error message. I have...
Nigel Price
May 19, 2017Iron Contributor
May 19, 2017
Hi Nigel Price
this works when https://mytenant.sharepoint.com/sites/sitename is a site collection:
Connect-PnPOnline https://mytenant.sharepoint.com/sites/sitename $webs= Get-PnPSubWeb $web = $web[1] # (to select the first one) Get-PnPList
If you then want to go to a subweb you will need to use something like this:
Connect-PnPOnline https://mytenant.sharepoint.com/sites/sitename $webs= Get-PnPSubWeb $web = $web[1] # (to select the first one) Get-PnPList
Or of course:
Connect-PnPOnline https://mytenant.sharepoint.com/sites/sitename
$web = Get-PnPSubWeb | where {$_.Title -eq "My Title"}
Get-PnPList
If you need a subsubweb then you could do this:
Connect-PnPOnline https://mytenant.sharepoint.com/sites/sitename
$web = Get-PnPSubWeb | where {$_.Title -eq "My Title"}
$subweb = Get-PnPSubWeb -Web $web | where {$_.Title -eq "My Sub Title"}
Get-PnPList