SharePoint Online: Bulk Update All Items in Large List using PowerShell

Requirement: Bulk Update SharePoint Online List Items using PowerShell.

PowerShell to Bulk Update All Items in Large List in SharePoint Online

How to update a Large Number of List Items in Bulk using PowerShell?

Are you looking for a way to quickly update all items in a SharePoint Online list? Maybe a column value needs to be updated for all items in the list. This article will show you how to use the PowerShell script to quickly bulk update all list items in SharePoint Online.

While lists with < 5000 items can be updated using the approach in my other post, Update SharePoint Online List using PowerShell, How about updating large lists with more than 5000 list items and avoid “The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator.” issue in PowerShell?

Well, large lists must be updated in batches. Here is my PowerShell script to update large lists in bulk: This PowerShell script updates the “Title” field value from “File Name”.

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
$SiteURL = ""
$ListName = "Documents"
$UserName = ""
$Password = "Password123456"
$SecurePassword= $Password | ConvertTo-SecureString -AsPlainText -Force
$BatchSize =100
#Setup the Context
$Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
$Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($UserName, $SecurePassword)
#Get the List
$List = $Ctx.Web.Lists.GetByTitle($ListName)

#sharepoint online powershell caml batch update
$Query = New-Object Microsoft.SharePoint.Client.CamlQuery
$Query.ViewXml = "@
    <View Scope='RecursiveAll'> 
             <OrderBy><FieldRef Name='ID' Ascending='TRUE'/></OrderBy>

#Get List Items in Batches
    #Get List Items 
    $ListItems = $List.GetItems($Query)

    #Update Postion of the ListItemCollectionPosition
    $Query.ListItemCollectionPosition = $ListItems.ListItemCollectionPosition

    If ($ListItems.Count -eq 0) { Break }
    #Update List Item
    ForEach($Item in $ListItems)
        #Update List Item Title as File Name
        $Item["Title"]= $Item["FileLeafRef"]
}While ($Query.ListItemCollectionPosition -ne $null)

If you want to bulk update multiple items from a CSV file, use: Update SharePoint Online List from a CSV using PowerShell

PnP PowerShell to Update All Items in a SharePoint Online List

Updating multiple list items using PnP PowerShell is relatively easier than the above CSOM script (That’s the Power of PnP!).

$SiteURL = ""
$ListName = "Projects"

#Connect to SharePoint Online site
Connect-PnPOnline $SiteURL -Interactive

#Get all Items from the list
$ListItems = Get-PnPListItem -List $ListName -PageSize 2000

#Update all list Items
ForEach($Item in $ListItems)
    #Update List Item Title as its ID value
    Set-PnPListItem -List $ListName -Identity $Item.Id -Values @{"Title"= $Item.Id} | Out-Null
    Write-host "Updated Item:"$Item.ID    

You can also use the PnP PowerShell’s New-PnPBatch method to bulk update list items faster! Here is the reference: SharePoint Online: Perform Bulk Operations with New-PnPBatch in PowerShell

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

7 thoughts on “SharePoint Online: Bulk Update All Items in Large List using PowerShell

  • Could you plz let me know how to insert items in SharePoint list in batches so that i can minimize the number of calls to server?

  • While going for pnp method, it will take longer time to execute the “Set-PnPListItem” command, right?
    How can we improve it’s performance

  • I haven’t been able to get this to work on lists over 5000. On lists under 5000 items, I see that it processes items in batches of 100 and have verified that the items have been updated. On a list over 5000, I get the dreaded “The attempted operation is prohibited because it exceeds the list view threshold enforced by the administrator”

    • This now works. Thank you so much!

      I’m not very strong in the Power Shell world yet, I truly appreciate your help.


Leave a Reply

Your email address will not be published. Required fields are marked *