I'm currently working on a script to update a SharePoint list in a 2013 Dedicated environment.
One of the fields on the list is a Multi-Valued 'People Picker' field and I can't figure out how to properly set its value using Powershell and the Microsoft.SharePoint.Client namespace.
I have a list of Usernames in the format of 'domain\username'. I'm iterating through each and calling SPWeb.EnsureUser to get a Microsoft.SharePoint.Client.User object.
After that, I'm at a loss as to what I should be doing. Below is a example of what I've been trying. The EnsureUser function is just a helper function I wrote that retrieves the Web object from the current Site $context and then call $web.EnsureUser. Once this is done, however, my list item does not contain the user I would expect.
$userName = "whd\wholland"
$spuser = EnsureUser $context $user
if($spuser -ne $null){
#Really not sure what to do here.
$spuserValue = New-Object Microsoft.SharePoint.Client.FieldUserValue
$spuserValue.LookupId = $spuser.id
$listItem["AllOwners"] = @($spuserValue)
}
$listItem.Update()