I want to get all the files from the root folder and its sub-folders, now when I tried this script:

$customerFolderFiles = Get-PnPFolderItem -FolderSiteRelativeUrl $serverRelativeUrl -Recursive -ItemType File

this will not get the files inside the sub-folders and will only get the files inside the root folder, any fix for this?


1 Answer 1


The script will get all the items first, then do the fileter. In your case the cmdlet is like following

$customerFolders= $var | Where {$_.FieldValues.FileDirRef -eq $mainfolderUrl -and $_.FileSystemObjectType -eq "Folder"} 

$var is the collection of items. The script get all the items in $var then where clause start filter the data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.