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

更新SharePoint用户字段以仅接受人员-Powershell,sharepoint,powershell,Sharepoint,Powershell,我正在通过执行以下操作将字段添加到现有列表中 $spList.Fields.Add( "SourceManager", [Microsoft.SharePoint.SPFieldType]::User, $false ) $spList.Fields["SourceManager"].Indexed = $true; $spList.Fields["SourceManager"].EnforceUniqueValues = $true; $spList.Fields["

我正在通过执行以下操作将字段添加到现有列表中

$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();
这很好,但我还想将该字段设置为仅允许人员(而不是此处默认的人员和组)。我找不到背景


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

您可以在更新之前设置字段的选择模式。以下是两个选项:

$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();

您可以在更新之前设置字段的选择模式。以下是两个选项:

$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();