我有以下 csom 脚本来更新站点列并下推更改:
Add-Type -Path "Libraries\Microsoft.SharePoint.Client.dll"
Add-Type -Path "Libraries\Microsoft.SharePoint.Client.Runtime.dll"
$webUrl = "enter_url_here"
$username = "enter_username_here"
$password = "enter_password_here"
$securePass = ConvertTo-SecureString $password -AsPlainText -Force
$ctx = New-Object Microsoft.SharePoint.Client.ClientContext($webUrl)
$ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($username, $securePass)
#Add description to the "Other category" field
$fieldTitle = "Other category"
$fieldDesc = "Search for an existing name before adding new entries"
$field = $ctx.Site.RootWeb.Fields.GetByInternalNameOrTitle($fieldTitle)
$field.Description = $fieldDesc
$field.UpdateAndPushChanges($true)
#Add description to the "Initiator location" field
$field2Title = "Initiator location"
$field2 = $ctx.Site.RootWeb.Fields.GetByInternalNameOrTitle($field2Title)
$field2.Description = $fieldDesc
$field2.UpdateAndPushChanges($true)
#Setting the "Main-category" field as required/mandatory
$field3Title = "Main-category"
$field3 = $ctx.Site.RootWeb.Fields.GetByInternalNameOrTitle($field3Title)
$field3.Required = $true
$field3.UpdateAndPushChanges($true)
$ctx.ExecuteQuery()
上述字段/列都是称为“主文档”的站点内容类型的一部分。
到目前为止,这工作正常,但是对于“主类别”字段,如何在内容类型级别将其设置为“必需”?目前这仅在网站栏级别设置,实现这一目标的最简单方法是什么?
非常感谢。