Closed colonelclaypoo closed 6 years ago
I used a somewhat different approach, which worked for me:
$users = (Get-PnPGroup | Where-Object {$_.Title -eq "Members"}).Users | Where-Object {$_ -notlike "*ext"} | select -ExpandProperty Id
Set-PnPListItem -List $list -Values @{$columnNameToAdd = $users}
Notice that I am adding the users by id.
Thanks for reply. That works for me.
select -ExpandProperty Id
in case that this information may become helpful to any: I also had to convert that UserId into a string, in order to get the Add-PnPListItem
This does not work for me. I am unable to set multiple values to a Person/Group column. It only writes the first value in the list of values.
This does not work for me. I am unable to set multiple values to a Person/Group column. It only writes the first value in the list of values.
Do a rest query and inpect how the data related to that column is formatted ( when it has more that one value ), then mimic that format when doing the update. Should work
Reporting an Issue or Missing Feature
Set-PnPListItem
does not seem to accept array variables passed to the hastable in the value position.Expected behavior
Specifying muliple values for a PersonField works if enclosed in double quotes and separated by commas. I would expect the same to work for a array-variable that is passed as the value for the PersonField in the hashtable.
Actual behavior
This code works:
Set-PnPListItem -List $list -Values @{$Column1= "test1@contoso.com","test2.contoso.com"}
This code does not work:
Set-PnPListItem -List $list -Values @{$Column1= $users}
Steps to reproduce behavior
I'm not sure if it's due to the way the $users array was created.
Here's how I needed to retrieve the values that ended up existing in the array:
$users = ($SiteSecurityGroups | Where-Object {$_.Title -eq "Members"}).Users | Where-Object {$_ -notlike "*ext*"}
.For reference,
$SiteSecurityGroups
contains values retrieved withGet-SPOSiteGroup -Site $site
.$users
should contain the users' email addresses that are retrieved from a site collection security group called "Members" and that do not contain "ext" in the email address name.I hope this makes sense to you.
$user -is [system.array] evaluates to True so it should be an array. However, Set-PnPListItem does not accept it. The error message I get is:
`Set-PnPListItem : The specified user could not be found (translated from German). In Zeile:1 Zeichen:92
Thanks for your input.
Which version of the PnP-PowerShell Cmdlets are you using?
What is the version of the Cmdlet module you are running?
ModuleType Version ExportedCommands
How did you install the PnP-PowerShell Cmdlets?