更新SharePoint用户字段以仅接受人员 - Powershell

时间:2013-08-08 09:13:30

标签: sharepoint powershell

我正在通过执行...

将字段添加到现有列表中
$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();

这很好,但我还想将字段设置为仅允许人(不是人和组,这是默认行为)。我找不到设置。

有人能指出我正确的方向吗?

1 个答案:

答案 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();