我正在通过执行...
将字段添加到现有列表中$spList.Fields.Add(
"SourceManager",
[Microsoft.SharePoint.SPFieldType]::User,
$false
)
$spList.Fields["SourceManager"].Indexed = $true;
$spList.Fields["SourceManager"].EnforceUniqueValues = $true;
$spList.Fields["SourceManager"].Required = $true;
$spList.Fields["SourceManager"].Update();
这很好,但我还想将字段设置为仅允许人(不是人和组,这是默认行为)。我找不到设置。
有人能指出我正确的方向吗?
答案 0 :(得分:1)
您可以在更新之前为字段设置选择模式。这两个选项如下:
$spList.Fields.Add(
"SourceManager",
[Microsoft.SharePoint.SPFieldType]::User,
$false
)
$spList.Fields["SourceManager"].Indexed = $true;
$spList.Fields["SourceManager"].EnforceUniqueValues = $true;
$spList.Fields["SourceManager"].Required = $true;
$spList.Fields["SourceManager"].SelectionMode = [Microsoft.SharePoint.SPFieldUserSelectionMode]::PeopleAndGroups; # For people and groups.
$spList.Fields["SourceManager"].SelectionMode = [Microsoft.SharePoint.SPFieldUserSelectionMode]::PeopleOnly; # For people only.
$spList.Fields["SourceManager"].Update();