Update All Items in a SharePoint List using PowerShell

Use these PowerShell scripts to update all items in SharePoint lists:

SharePoint PowerShell script to update all items in a list:

Requirement is to update all items in a SharePoint list using PowerShell script:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

### Variables ###
#Site URL and List names
$SiteURL = "https://intranet.crescent.com/"
$ListName = "Business Contacts"                 

#Get site and List objects
$web = Get-SPWeb $SiteURL
$List = $web.Lists.TryGetList($ListName)

if($List -ne $null)
    {    
        #Get all List items
        $ListItems = $list.Items
        
        #Iterate through each item
        Foreach($item in $ListItems)
        {
            #To update a particular field, 
            $item[$FieldName]= NewValue;

            #sharepoint powershell update all items in list
            $item.update()
        }
    }
#dispose web object
$web.Dispose() 

Filter and Update all documents in a SharePoint Library:

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

### Variables ###
#Site URL and List names
$SiteURL = "https://intranet.crescent.com/Sites/Sales"
$ListName = "Sales Proposals" 
#Column to update
$FieldName ="Sales Category"
#Field old and new values
$OldValue = "Software"
$NewValue="Applications"

#Get site and List objects
$web = Get-SPWeb $SiteURL
$List = $web.Lists.TryGetList($ListName)

if($List -ne $null)
{
	#Get all documents with .docx extension
	$DocsCollection = $List.Items | where {$_.Name -match ".docx"}
	
	#Iterate through each document
	foreach ($Doc in $DocsCollection)
	{
		#Change Category Metadata
		if($Doc[$FieldName] -eq $OldValue)
		{
			$Doc[$FieldName] = $NewValue

			#Perform a system update to keep versions, Modified by metadata intact
			$Doc.SystemUpdate($false)
			write-host "Updated an item at: $($doc.URL)"
		}
	}
}

#dispose web object
$web.Dispose() 

This PowerShell script selectively updates all document’s metadata, residing in a library – Including the one inside folders.

Here is an another trick to trigger update on multiple documents in SharePoint:

  • Navigate to your document library
  • Select required documents >> Click on “Check Out” button from ribbon
  • Click on “Check-in”
Update All Items in a SharePoint 2013

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!

Leave a Reply

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