I have the following script :
$site = new-object Microsoft.SharePoint.SPSite("http://TEST123") $web = $site.OpenWeb() $ct=$web.ContentTypes["MyCT"] $field = $ct.Fields.GetFieldByInternalName("AddTESTColumn") $ct.FieldLinks[$field.id].DisplayName ="AddTESTColumn" $ct.Update();
I have used the above to update the display name of a column that is associated to CT.
But now I want to update a choice field column so will be adding a new choice "away" to the current choices tried to use the choices.add but keep getting error message
I used the following :
$site = Get-SPSite -Identity "http://TEST123" $web = $site.RootWeb $field = $web.Fields["AddTESTColumn"]; $field.choices.add("away") $field.update();
and get the following message:
You cannot call a method on a null-valued expression.
the issue is with
$field = $web.Fields["AddTESTColumn"]; as its not recognising the field name even though it exist. I have used both internal and display name, same issue.