Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Add More Than 5000 Items to a SharePoint List Using PnP PowerShell

You need a SharePoint list with thousands of rows for a migration, a load test or a delegation demo. Adding them one at a time takes close to an hour.

In this tutorial, we’ll show you how to add more than 5000 items to SharePoint list using PnP PowerShell batching, straight from a CSV file. Every timing and count below comes from a real run in our tenant.

Quick answer: Create a batch with New-PnPBatch, queue each row with Add-PnPListItem -Batch $batch, then send it with Invoke-PnPBatch, about 500 rows per chunk. The 5,000 limit is a view and query threshold, not a storage limit.

What You Need Before You Start

Step 1: Create the List and Index Columns Before It Grows

Our sample list, SPGDemo Bulk Items, has Customer, Region, Amount and Order Date columns. We index Region and Order Date while the list is empty, because views will filter on them. Indexed columns in SharePoint lists the column types that qualify (up to 20 per list).

Connect-PnPOnline -Url "https://spguides.sharepoint.com/sites/SPGuides" -ClientId "<your-app-client-id>" -Interactive
$listName = "SPGDemo Bulk Items"

New-PnPList -Title $listName -Template GenericList | Out-Null
Add-PnPField -List $listName -DisplayName "Customer" -InternalName "Customer" -Type Text | Out-Null
Add-PnPField -List $listName -DisplayName "Region" -InternalName "Region" -Type Choice `
    -Choices "East", "West", "Central", "South" | Out-Null
Add-PnPField -List $listName -DisplayName "Amount" -InternalName "Amount" -Type Currency | Out-Null
Add-PnPField -List $listName -DisplayName "Order Date" -InternalName "OrderDate" -Type DateTime | Out-Null

# Index the columns you'll filter on BEFORE the list grows
Set-PnPField -List $listName -Identity "Region" -Values @{ Indexed = $true }
Set-PnPField -List $listName -Identity "OrderDate" -Values @{ Indexed = $true }

Get-PnPField -List $listName |
    Where-Object InternalName -in "Title", "Customer", "Region", "Amount", "OrderDate" |
    Select-Object Title, InternalName, TypeAsString, Indexed | Format-Table -AutoSize
PnP PowerShell script in VS Code creating the SPGDemo Bulk Items list and indexing the Region and Order Date columns

Both columns show Indexed = True. Microsoft warns that creating an index can be blocked once a list is over the threshold, so do it first. More column options are in creating a SharePoint list with PnP PowerShell.

Step 2: Prepare the CSV File

Name each CSV header after the column’s internal name. Our bulk-orders.csv has 5,200 rows:

Title,Customer,Region,Amount,OrderDate
SO-26001,Ryan Hayes,West,7073.36,07/07/2026
SO-26002,Robert Bryant,East,2663.52,01/02/2026

Use the site’s regional format for dates and numbers, because batched calls read them that way (ours is English, United States). Starting from a workbook? See adding items from an Excel file to a SharePoint list.

Step 3: Add the Items in Batches with New-PnPBatch

The script splits the rows into chunks of 500, queues each chunk in a fresh batch and sends it with one Invoke-PnPBatch call:

$listName  = "SPGDemo Bulk Items"
$rows      = Import-Csv -Path ".\bulk-orders.csv"
$chunkSize = 500
"Rows in CSV: {0:N0}" -f $rows.Count
$total = [Diagnostics.Stopwatch]::StartNew()

for ($i = 0; $i -lt $rows.Count; $i += $chunkSize) {
    $chunk = $rows[$i..([Math]::Min($i + $chunkSize, $rows.Count) - 1)]
    for ($try = 1; $try -le 3; $try++) {
        try {
            $timer = [Diagnostics.Stopwatch]::StartNew()
            $batch = New-PnPBatch
            foreach ($r in $chunk) {
                Add-PnPListItem -List $listName -Batch $batch -Values @{
                    Title = $r.Title; Customer = $r.Customer; Region = $r.Region
                    Amount = $r.Amount; OrderDate = $r.OrderDate
                }
            }
            Invoke-PnPBatch -Batch $batch -StopOnException
            "Rows {0,5:N0}-{1,5:N0} added in {2,5:N1} s" -f ($i + 1), ($i + $chunk.Count), $timer.Elapsed.TotalSeconds
            break
        }
        catch {
            Write-Warning "Chunk at row $($i + 1) failed (try $try): $($_.Exception.Message)"
            Start-Sleep -Seconds (30 * $try)
        }
    }
}
"Total: {0:N0} rows in {1:N1} minutes" -f $rows.Count, $total.Elapsed.TotalMinutes
Import-BulkItems.ps1 in VS Code adding 5,200 CSV rows to a SharePoint list with New-PnPBatch and Invoke-PnPBatch in 500-row chunks

All 5,200 rows landed in 5.0 minutes, 26.8 to 30.8 seconds per full chunk, with no retries. Chunks keep memory flat, show progress and limit a failure to 500 rows. -StopOnException hands the first error to the catch block.

Step 4: Handle Throttling (HTTP 429 and 503)

When a script sends too many requests, SharePoint Online returns HTTP 429 or 503 with a Retry-After header. PnP PowerShell already retries those (and 504) up to 10 times, waits as Retry-After says, and retries a SharePoint batch as a whole.

Our $try loop is the safety net when those retries run out: it waits 30, then 60 seconds. Run big imports at night or on weekends. Important: a failed chunk may have saved some rows, so check the count before you rerun it.

Step 5: Verify the Item Count

ItemCount is instant; Get-PnPListItem -PageSize reads every item, which proves the list works past 5,000:

$listName = "SPGDemo Bulk Items"

# Fast: the count SharePoint stores on the list
(Get-PnPList -Identity $listName).ItemCount

# Real read of every item, 2,000 per request (paging stays under the threshold)
$timer = [Diagnostics.Stopwatch]::StartNew()
$items = Get-PnPListItem -List $listName -PageSize 2000 -Fields "Title", "Region"
"Read {0:N0} items in {1:N1} s" -f $items.Count, $timer.Elapsed.TotalSeconds

$items | Group-Object { $_["Region"] } | Select-Object Name, Count | Format-Table -AutoSize
Get-PnPList ItemCount and Get-PnPListItem -PageSize 2000 in VS Code verifying 5,250 items in the SharePoint list

The list holds 5,250 items (the 5,200 batched rows plus 50 from our one-by-one test), read in 1.9 seconds. To start over, delete all items from a SharePoint list with the same batch pattern.

Batch vs One-by-One: Cheat Sheet

TaskWhat we usedOur result
Add a few itemsAdd-PnPListItem in a loop0.58 s per item (50 items in 28.8 s)
Add 5,000+ itemsNew-PnPBatch + Add-PnPListItem -Batch5,200 items in 5.0 min, about 10x faster
Update many itemsSet-PnPListItem -Identity -BatchSame batch pattern
Count itemsGet-PnPList ItemCount5250, instant
Read all itemsGet-PnPListItem -PageSize 20005,250 items in 1.9 s

At 0.58 seconds per item, a plain loop would need about 50 minutes for 5,200 rows.

Does the 5,000-Item Threshold Stop You From Adding Items?

No. A list can store up to 30 million items. The 5,000 list view threshold, which can’t be changed in SharePoint Online, blocks views and queries that scan too many items, not inserts. On our list, a filter on the non-indexed Customer column fails while the indexed Region filter works:

$listName = "SPGDemo Bulk Items"

# Filter on Customer (NOT indexed)
$q1 = "<View><Query><Where><Eq><FieldRef Name='Customer'/><Value Type='Text'>Emily Carter</Value></Eq></Where></Query></View>"
try   { (Get-PnPListItem -List $listName -Query $q1 -ErrorAction Stop).Count }
catch { "Customer filter failed:"; $_.Exception.Message }

# Filter on Region (indexed before the import)
$q2 = "<View><Query><Where><Eq><FieldRef Name='Region'/><Value Type='Choice'>West</Value></Eq></Where></Query></View>"
"West items (indexed Region): {0:N0}" -f (Get-PnPListItem -List $listName -Query $q2).Count
CAML query in VS Code failing on a non-indexed column and returning 1,316 items on the indexed Region column of a 5,250-item list

Fixes for existing large lists are in the list view threshold error guide.

Common Mistakes to Avoid

  • Display names in -Values: use internal names; a renamed column keeps its old one.
  • Indexing too late: index while the list is small.
  • Reading without -PageSize: large reads can hit the threshold.
  • Live flows: a When an item is created flow runs once per new item, so turn it off during the import.

Next Steps

To change or clean the data in bulk, see CRUD operations on SharePoint list items; more scripts live in the SharePoint tutorials hub.

We use these alongside bulk imports:

Frequently Asked Questions

Can a SharePoint Online list hold more than 5,000 items?

Yes, up to 30 million. The 5,000 list view threshold limits views and queries, not storage.

How many items should I put in one PnP batch?

PnP documents no hard limit. Our 500-row chunks took about 30 seconds each. See the New-PnPBatch reference.

Why does my bulk import get HTTP 429 or 503 errors?

SharePoint is throttling the script. PnP retries automatically; if it still fails, slow down and run off-peak, as Microsoft explains.

Can I update more than 5,000 items with Set-PnPListItem?

Yes. Set-PnPListItem has a -Batch parameter, so updates by item ID work like the inserts here.

Does Get-PnPListItem work on lists with more than 5,000 items?

Yes, with -PageSize or a CAML filter on an indexed column. Filters on non-indexed columns fail with the threshold error.