I'm trying to change the setting of a column to make it not a required field. This is the code I'm using:
$site = new-object Microsoft.SharePoint.SPSite("abc.com") $web = $site.OpenWeb()
$MyContentType=$web.ContentTypes["ContentType"] $MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id} $MyContentType.FieldLinks[$MyField.Id].Required=$False
$MyContentType.Update()
$site = new-object Microsoft.SharePoint.SPSite("abc.com")
$web = $site.OpenWeb()
$MyContentType=$web.ContentTypes["ContentType"]
$MyField=$MyContentType.Fields | Where {$_.Id -eq $web.Fields["Column"].id}
$MyContentType.FieldLinks[$MyField.Id].Required=$False
$MyContentType.Update()
But this is giving error that $MyContentType.FieldLinks$MyContentType.FieldLinks
is NULLNULL
. How can I successfully execute my powershellPowerShell script?