Does the Where clause inside PnP Powershell performed on the client or on SharePoint side

john john 1,021 Reputation points
2023-07-23T17:03:16.9633333+00:00

I have this PnP PowerShell:-

$customerFolders= Get-PnPListItem -List $listName -PageSize 5000 -Fields "Id", "FileLeafRef", "Modified","FileDirRef","FileSystemObjectType" -Script {
    
    Start-Sleep -Seconds 5;
    Write-Host "building CustomerFolders..." 
} 
 | Where {$_.FieldValues.FileDirRef -eq $mainfolderUrl -and $_.FileSystemObjectType -eq "Folder"} 


so how will this script work? will the script get all the data from sharepoint in batches of 5,000 and do the filtering on the client? or the filtering will be done on the SharePoint side?

Thanks

Microsoft 365 and Office | SharePoint | Development
Microsoft 365 and Office | SharePoint | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. RaytheonXie_MSFT 40,471 Reputation points Microsoft External Staff
    2023-07-24T02:02:21.9933333+00:00

    Hi @john john,

    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.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.