Introduction
Welcome readers to an article on updating list items in SharePoint 2013 and Office 365 using PowerShell.
Here we will see how to update all the list items in a list when a requirement of such comes in.
I have a PowerShell script here that you just need to add using Notepad and save it as a .ps1 file. In this script I am updating a choice field from a look up field.
Script
- Add-PSSnapin Microsoft.SharePoint.PowerShell -EA SilentlyContinue
- $webURL = "Your Site Url"
- $listName = "Name of your list"
- $web = Get-SPWeb $webURL
- $list = $web.Lists[$listName]
- $items = $list.items
- Foreach($item in $items)
- {
- $prim = $item["Look Up Column field"]
- if(!$prim)
- {
- write-host "Null"
- }
- else
- {
- $trim = $prim.split('#')[1]
- write-host $trim
- $item["choice field"] = $trim
- $item.Update()
- write-host $item["Your Result You want to see"]
- }
- }
How to run
- You need to change the fields Site Url, List Name and Fields.
- You might have a question, why am I using a split function?
The field value when fetched from a look up field has characters like “1,#”. Using split we eliminate that extra data by giving us a correct variable.
- Run the SharePoint PowerShell as Administrator
- Run the .ps1 file
Here is a time saver article for my readers. Keep learning.
Cheers!

Sr KarthigaPosted Apr 19, 2016, 10:18 PM
Nice explanation
Rahul Kumar SaxenaPosted Feb 25, 2015, 12:20 PM
Good Work bro..
Sibeesh VenuPosted Feb 23, 2015, 10:20 PM
Manpreet Singh You are welcome
Manpreet SinghPosted Feb 23, 2015, 2:38 PM
Thanks Sibeesh Venu !
Sibeesh VenuPosted Feb 21, 2015, 1:10 AM
Good One .