Forum Discussion
Blair24
Feb 15, 2019Copper Contributor
Set-PnPListItem - Multiple User Field
Hey Folks,
Trying to update a List item via PowerShell, the column is a multiple user field.
The updated users are currently in an array of Email Addresses which is causing an error.
Wondering if anyone knows how I could easily convert this to a string or if there's a workaround?
Thanks!
- Thomas BermanIron Contributor
Hi Blair,
An array of email addresses is definitely supported.
I just tested this out passing in an array of email address strings and it worked fine. Here's the exact syntax:
$users = "user@contoso.com", "user2@contoso.com"
Connect-PnPOnline -Url https://contoso.sharepoint.com
Set-PnPListItem -List "test1" -Identity 1 -Values @{"TestPeopleMulti"=$users}
This updated the user-multi field with both users.
- Blair24Copper Contributor
Hi Thomas,
Yeah I've done it before, my script below is still causing an error:$salesmangers = $ListItem.SalesManager.Email
$salesmangers += $newmanager
$newlistofmanagers = $salesmangers | Where-Object { $_ –ne $currentmanger }
Set-PnPListItem -List $customerlistID -Identity $ListItem.ID -Values @{"SalesManager" = $newlistofmanagers}- Thomas BermanIron Contributor
What error are you getting and where is it failing?
Also, to access that field, try $salesmangers = $ListItem.FieldValues.SalesManager.Email