如何在多用户人员选择器字段(人员或组字段)中添加多个用户

时间:2019-04-11 14:07:30

标签: powershell sharepoint-online

我想在SharePoint列表中的“多个选择人”字段中添加多个用户。 我尝试了以下代码,但始终收到以下错误消息:

  

新对象:找不到类型[Microsoft.SharePoint.SPFieldUserValueCollection]:验证是否已加载包含此类型的程序集。

有人可以帮助我解决此问题吗?

exports.OT = t()

1 个答案:

答案 0 :(得分:0)

您可以轻松使用PnP Powershell

#region Variables 
$Username = "lee@tenant.onmicrosoft.com" 
$Password = "pw" 
$siteURL = "https://tenant.sharepoint.com/sites/lee" 

#endregion Variables

#region Credentials 
[SecureString]$SecurePass = ConvertTo-SecureString $Password -AsPlainText -Force 
[System.Management.Automation.PSCredential]$PSCredentials = New-Object System.Management.Automation.PSCredential($Username, $SecurePass) 
#endregion Credentials

Connect-PnPOnline -Url $siteURL -Credentials $PSCredentials
$users = "user1@tenant.onmicrosoft.com", "user2@tenant.onmicrosoft.com"
Set-PnPListItem -List "MyList" -Identity 9 -Values @{"User"=$users}