SOLVED

Set-SPOListItem with multi-value people column

Visitor

If I do Set-SPOListItem with string variable it gives error. Please see following:

 

$value="David Longmuir","Conf Room Stevens"

Set-SPOListItem -List $bidDetailsList -Web $web -Values @{$key=$value} -Identity $itemCheck.Id

 

Error: Set-SPOListItem : The specified user "David Longmuir","Conf Room Stevens" could not be found.

 

The following line works:

Set-SPOListItem -List $bidDetailsList -Web $web -Values @{$key="David Longmuir","Conf Room Stevens"} -Identity $itemCheck.Id

 

What is the best way to set the multi-value people field using a variable?  As obviously I cannot hard code the usernames.

2 Replies

You can try

 

Set-SPOListItem -List $bidDetailsList -Web $web -Values @{$key=$value} -Identity $itemCheck.Id

$value=@("David Longmuir","Conf Room Stevens")

best response confirmed by Umair Naeem (Visitor)
Solution

Hi @Umair Naeem

 

I got this to work by doing the following:

 

$peopleArr = @()

$peopleArr += "ben@mytenant.onmicrosoft.com"
$peopleArr += "chris@mytenant.onmicrosoft.com"


Set-SPOListItem -List "testlist" -Identity 1 -Values @{"People"=$peopleArr}

 

I've now updated my blog post about this to include multi people columns:

https://veenstra.me.uk/2016/06/13/office-365-sharepoint-update-list-items-using-powershell/