How to Update List Items in SharePoint using PowerShell?

Requirement: Update List Items in SharePoint using PowerShell

Update List Items in SharePoint using PowerShell

How to Update List Items in SharePoint using PowerShell Script?

Well, the basic syntax for updating a list item goes as:

#Get Web and List 
$Web = Get-SPWeb ""
$List = $Web.Lists["ListName"]

#Get the List item to update
$ListItem = $List.GetItembyID($ItemID)
#Set Column values
$ListItem["ColumnName"] = "New Value for the Field!"
#Update the Item, so that it gets saved to the list

Update SharePoint list item using PowerShell script

Let’s take another example:

Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue

$web = Get-SPWeb

#Get the Contacts List
$List = $web.Lists["Contacts"]

#Get the List Item by its Title field value
$ListItem = $List.Items | Where {$_["Title] -eq "Salaudeen Rajack"}

#Set "Department" column value
$ListItem["Department"] = "IT"


Update All List items using PowerShell script:

$web = Get-SPWeb

#Get the Contacts List
$List = $web.Lists["Contacts"]

#Get All Items by update its title
$ListItems = $List.items
#Iterate through each item
foreach($Item in $ListItems)
    #Update the value of the "Title" column
    $item["Title"] = "Title Updated!"
    #Update the item

How about Updating Selective List Items in Bulk?

Let’s update a list item by its id field.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

$SiteURL = ""
$ListName = "Deals"

#Get the List
$List = (Get-SPWeb $SiteURL).Lists.TryGetList($ListName)

#List of Item IDs to update
$ItemIDs = 16,52,69,70,97,170,194,195,196,220,259

    foreach($ItemID in $ItemIDs)
        #Get Item by ID
        $ListItem = $List.GetItembyID($ItemID) 

        #Update List Item Fields
        $ListItem["Health and SafetyRisk"]="Low"
        $ListItem["Environmental Risk"]="Medium"
        $ListItem["Social Risk"]="High"       

        Write-host "Updated Item ID:"$ItemID

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

3 thoughts on “How to Update List Items in SharePoint using PowerShell?

  • June 26, 2020 at 2:04 PM

    The command item.update does deletes the values of the column before updating it.
    What if I do only want to update it without deleting before.
    Thank you

  • January 22, 2019 at 9:46 AM

    Get-SPWeb : The term ‘Get-SPWeb’ is not recognized as the name of a cmdlet,
    function, script file, or operable program. Check the spelling of the name, or
    if a path was included, verify that the path is correct and try again.
    At line:4 char:1
    + Get-SPWeb
    + ~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (Get-SPWeb:String) [], CommandNo
    + FullyQualifiedErrorId : CommandNotFoundException

    And When i try to Add-PSSnapin “Microsoft.SharePoint.PowerShell”

    Add-PSSnapin : The Windows PowerShell snap-in
    ‘Microsoft.SharePoint.PowerShell’ is not installed on this computer.
    At line:1 char:1
    + Add-PSSnapin “Microsoft.SharePoint.PowerShell”
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : InvalidArgument: (Microsoft.SharePoint.PowerShel
    l:String) [Add-PSSnapin], PSArgumentException
    + FullyQualifiedErrorId : AddPSSnapInRead,Microsoft.PowerShell.Commands.Ad

    • August 29, 2020 at 8:40 AM

      You must run this PowerShell from any of the SharePoint Servers of your SharePoint Farm (and not from your desktop!)


Leave a Reply