Get-PnPListItem error

ネパリ サンデャ 460 Reputation points
2023-06-30T07:37:56.7933333+00:00

I get this error while running following commd

Get-PnPListItem: This operation cannot be performed because the list view threshold has been exceeded error

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,880 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,062 questions
SharePoint Server Management
SharePoint Server Management
SharePoint Server: A family of Microsoft on-premises document management and storage systems.Management: The act or process of organizing, handling, directing or controlling something.
2,967 questions
PowerPoint Management
PowerPoint Management
PowerPoint: A family of Microsoft presentation graphics products that offer tools for creating presentations and adding graphic effects like multimedia objects and special effects with text.Management: The act or process of organizing, handling, directing or controlling something.
232 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,627 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Ling Zhou_MSFT 18,325 Reputation points Microsoft Vendor
    2023-06-30T08:48:00.0266667+00:00

    Hi @ネパリ サンデャ,

    Thank you for posting in this community.

    The reason for your problem is that SharePoint Online contains a maximum of 5000 items in a list view.

    The reason for your problem is that SharePoint Online contains a maximum of 5000 items in a list view.

    Here's a reference to this limitation: "The number of items in this list exceeds the list view threshold" when you view lists in Microsoft 365

    For your question, the PnP PowerShell module provides a “PageSize” switch to handle larger lists in batches:

    
    #Parameter
    $SiteURL = "https://crescent.sharepoint.com/sites/PMO"
    $ListName= "Projects"
      
    #Connect to PnP Online
    Connect-PnPOnline -Url $SiteURL -Interactive
     
    #Get all list items from list in batches
    $ListItems = Get-PnPListItem -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"]
    }
    
    

    Here is the link to the referenced solution

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link. 


    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.