Add-PnPDataRowsToSiteTemplate error- The attempted operation is prohibited because it exceeds the list view threshold

YavapaiR 15 Reputation points
2024-07-30T01:51:48.91+00:00

Hello everyone,

I'm copying a list from one site to another, in SharePoint Online, I'm following these steps by Salaudeen Rajack from this post:

#Parameters

$SourceSiteURL = "https://crescent.sharepoint.com/sites/Retail"

$TargetSiteURL = "https://crescent.sharepoint.com/sites/Sales"

$ListName= "Projects"

$TemplateFile ="$env:TEMP\Template.xml"

#Connect to the Source Site

Connect-PnPOnline -Url $SourceSiteURL -Interactive

#Create the Template

Get-PnPSiteTemplate -Out $TemplateFile -ListsToExtract $ListName -Handlers Lists

#Get Data from source List

Add-PnPDataRowsToSiteTemplate -Path $TemplateFile -List $ListName

#Connect to destination Site

Connect-PnPOnline -Url $TargetSiteURL -Interactive

#Import the exported list - Apply the Template

Invoke-PnPSiteTemplate -Path $TemplateFile

When I run the step Add-PnPDataRowsToSiteTemplate -Path $TemplateFile -List $ListName, I get the error "The attempted operation is prohibited because it exceeds the list view threshold." I know this error is because of the threshold limitation of 5000 items, my list has over 10 thousand items.
Do you guys have any advise in how I could copy this list to my other site?
I can not use a cloud flow because I need all the metadata (created by, modified by, item ID, etc) from the original list.

Thank you so much in advance for your help!
Best Regards. :)

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,830 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. AllenXu-MSFT 21,121 Reputation points Microsoft Vendor
    2024-07-31T07:33:19.13+00:00

    Hi @YavapaiR,

    For large list which exceeds list view threshold, you can export the list to CSV with schema. And create a new list from CSV.

    User's image

    Or you can import the CSV file to an existing list using PowerShell. Reference: SharePoint Online: Import CSV File into SharePoint List using PowerShell.


    If the answer is helpful, please click "Accept as 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.

    0 comments No comments

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.