I have a SharePoint online site which contain a document library named "Customer Share" >> and inside this library we have a folder named "Clients" >> and inside the "Clients" folder we have around 10,000 sub-folders representing clients.

Now i am trying to get all the 10,000 sub-folders >> then for each sub-folder to see what is the maximum last modified date of its content.

Now first step i tried to get the 10,000 sub-folders in batches to avoid any threshold error:-

$mainfolderUrl = "Customer Share/Clients" 
$customerFolders = Get-PnPFolderItem -FolderSiteRelativeUrl $mainfolderUrl -PageSize 3000  -ScriptBlock {}

but i got this error:-

Get-PnPFolderItem: A parameter cannot be found that matches parameter name 'PageSize'.

so can anyone advice how i can get the 10,000 sub-folders in batches?


1 Answer 1


According to my research and testing, if you want to get items from larger lists with more than 5000 items, you should use PageSize to handle larger lists in batches ,please try to use the following PowerShell script:

$SiteURL = "https://xxxx.sharepoint.com/sites/xxx"  
$ListName= "xxx"  
#Connect to PnP Online  
Connect-PnPOnline -Url $SiteURL   
#Get all list items from list in batches  
$ListItems = Get-PnPFolderItem  -List $ListName -PageSize 500  
Write-host "Total Number of List Items:" $($ListItems.Count)  
#Loop through each Item  
ForEach($Item in $ListItems)  
    Write-Host "Id :" $Item["ID"]  
    Write-Host "Title :" $Item["Title"]  
  • but you can not pass a paramter name -PageSize for Get-PnPFolderItem Commented Jul 19, 2023 at 12:08

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.