I need to write a PowerShell script to update a choice column with a specific value in all the items of a List. Following is the main part of the script

$siteUrl = "http://mySharePointSiteUrl/"    

$SPWeb = Get-SPWeb $siteUrl

$SPList = $SPWeb.Lists["ListName"]

$listItems = $SPList.Items;

foreach($item in $listItems){
    $item["ChoiceColumnName"] = "Choice1"

This approach works for list with small number items, but will it be efficient for list having more than 5000 items?
Is there any other way for the same ?

  • Your script is not setting the default value, it is setting the value of the field for each list item. That is different. And yes, 5000 items wouldn't be an issue. Mar 4, 2016 at 13:55
  • I want to set a specific choice value, not default value. My mistake. Updated my Question.
    – Yayati
    Mar 4, 2016 at 14:00

2 Answers 2


Change $item.update(); to $item.SystemUpdate(false) which won't increase the version number. 5000 items shouldn't be a strugle for SharePoint if you don't have any custom event receivers attached. In that case you could pause the script after every update for a part of the second to catch up with SharePoint (don't think it's necessary, tho) - Start-Sleep -m 100 (that would pause the script for 100ms). Dispose of the SPWeb at the end by calling $SPWeb.Dispose(); and you'll be all good to go.

  • Instead of pausing for 100ms can we stop event receivers from getting fired ?
    – Yayati
    Mar 8, 2016 at 13:25
  • Have you got any custom ones? Mar 8, 2016 at 13:31
  • I don't know exactly because I will be using this code for more than 20 lists in the sites
    – Yayati
    Mar 8, 2016 at 13:38
  • I wouldn't disable them if I was in your place as the event receivers might be responsible for different background tasks. I would go with a start-sleep command. You can check if there are event receivers attached to the list by running the following PowerShell command: $SPList.EventReceivers.Count . Keep in mind there might be default ootb event receivers like Taxonomy etc. You don't want to disable those. Mar 8, 2016 at 13:53
  • That is very useful insights on this. Thanks for your suggestions.
    – Yayati
    Mar 8, 2016 at 19:15

As said, updating some 5000 items should no be a problem. However, you could reduce "server stress" by using the bulk updates.

Have a look at SPWeb.ProcessBatchData

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.