Monday, June 8, 2020

Get-PnPListItem in a list with greater than 5000 items

If you need to grab all the items from a list with greater than 5000 items in SharePoint Online, you might get the following error:

The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator

To get around that, add a query with the scope of RecursiveAll to your query like so:

Connect-PnpOnline -Url 'https://vivity.sharepoint.com/sites/sitename' -Credentials (Get-Credential)
$query = "<View Scope='RecursiveAll'><RowLimit>5000</RowLimit></View>"
$items = Get-PnPListItem -List 'My List' -Query $query

No comments: