We have document library having records more than 25000 items including many folders. Using CSOM/JSOM need to get all root folders from Document Library (having more than 5000 items) and its all ItemChildCount (items including inside any subfolders) like below. I am able to get when items less than 5000. For more than 5000 I have tried using ListItemCollectionPosition, however the item count is not correct. I am expecting output like below (green box) item count. Appreciate your help. enter image description here

1 Answer 1


Same question:

$Folders = Get-PnPListItem -List $Listname -PageSize 100 -Fields FileLeafRef  | Where { $_.FileSystemObjectType -eq "Folder" }

when I have folder list over 5000 items I get:


get-pnplistitem, can it be set to not return folders recursively? can you do a top to just pull in the first 100 items found?


Your Answer

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

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