如何使用 PowerShell 更新列表字段属性?当我尝试以下操作时:
$site = Get-SPSite -Identity "http://vikas:26112/"
$web= $site.OpenWeb()
$spList = $web.GetList("/Lists/Support Links")
$spFieldType = [Microsoft.SharePoint.SPFieldType]::Text
$spList.Fields.Add("FirstName",$spFieldType,$false)
$spList.Fields[“FirstName”].Description = “My FirstName Field”
$spList.Fields[“FirstName”].Required=$true
$spList.Fields["FirstName"].EnforceUniqueValues=$true
$spList.update()
$web.Dispose()
执行后该FirstName
字段被添加到列表中,但该字段的属性保持不变:
Description =""
Required=false
EnforceUniqueValues=false