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...
May 19, 2017
Try the below. Currently it seems -web is not working, alternatively you can connect to each subsite and then get the lists in those subsite.
$cred= Get-Credential
connect-pnponline -Url https://tenantname.sharepoint.com/sites/contosobeta -Credentials $cred
$subwebs=Get-PNPSubWebs -Recurse
foreach($subweb in $subwebs)
{
Connect-PNPonline -Url $subweb.Url -Credentials $cred
Get-PnPList
}Nigel Price
May 19, 2017Iron Contributor
Hi NarasimaPerumal Chandramohan
it looks as if this might be a timing problem. If I run the two commands (Connect-PnPOnline and Get-PnPList) in a PowerShell (.ps1) file I get the error. If I run the two commands using the PowerShell Gui and typing them in then all works well.
Is there anyway I can get the second command wait until the first command finishes (or even run on a single thread.) ? If this was JavaScript ot TypeScript, then I could use promises. But in PowerShell ?
Regards
Nigel