Update Choice Field Value using Powershell SharePoint

  1. Add-PSSnapin Microsoft.SharePoint.PowerShell   
  2. $webURL = Read-Host "Please enter your SiteCollection Url"  
  3. $spSite = New-Object Microsoft.SharePoint.SPSite($webURL)  
  4. $web = $spSite.OpenWeb()  
  5.   
  6.   
  7. $list = $web.Lists["Customer"]  
  8. Write-Host “Updatiing Category field values' for:- ” $list.Title  -ForegroundColor Yellow  
  9. $CategoryField = $list.Fields["Categories"];  
  10. $ChoicesArray = @("Product related","Production"," (HR)"," Code of Business Conduct","Sustainability");  
  11.  
  12. #remove old values  
  13. $CategoryField.choices.clear()  
  14.  
  15. #update new values  
  16. $CategoryField.choices.addrange($ChoicesArray)  
  17. $CategoryField.Update()  
  18.   
  19.   
  20. Write-Host “Category field value updated successfully” -ForegroundColor Green  
  21.   
  22. $web.Dispose()  
  23. Remove-PSSnapin Microsoft.SharePoint.PowerShell