Oct 07 2016 03:25 AM
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.
Oct 07 2016 04:55 AM
You can try
Set-SPOListItem -List $bidDetailsList -Web $web -Values @{$key=$value} -Identity $itemCheck.Id
$value=@("David Longmuir","Conf Room Stevens")
Oct 07 2016 06:07 AM
SolutionHi @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/
Oct 07 2016 06:07 AM
SolutionHi @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/