【发布时间】:2021-10-19 09:09:46
【问题描述】:
我需要使用 PnP PowerShell 将一列的验证从 optional 更改为 required 仅在特定内容类型中。
我找到了 Set-PnPField 命令,但不确定如何使用它来仅更新特定内容类型的属性。以下是我目前编写的代码:
$FieldName = "<Internal Name of the Field>"
$ListName = "<Name of the List>"
# connect to the portal using client id and client secret key
Connect-PnPOnline -Url <SharePoint Site Collecton URL> -ClientId <Client ID> -ClientSecret <Client Secret Key>
# get the current web
$spWeb = Get-PnPWeb -ErrorAction SilentlyContinue
if($spWeb -ne $null)
{
#Get the Field from List
$Field = Get-PnPField -List $ListName -Identity $FieldName -ErrorAction Stop
#Set the Field Required
$Field.Required = $True
$Field.Update()
$Field.Context.ExecuteQuery()
}
此代码仅在列表级别更新字段验证。如果有任何方法可以满足要求,请帮助我。提前致谢。
【问题讨论】:
标签: powershell sharepoint sharepoint-online