1

I want to search for a cell value in a list and only update the match where items are multivalue cells. I'm not sure if my terminology is accurate but I hope I can explain what I mean.

I'm able to search and get a match but updating the values for multivalue cells overwrites all the cell values.

I have a minimal test list with one column: User

This column is of the type 'Person or Group'. In PS the property is called: TypedObject and its value is Microsoft.SharePoint.Client.FieldUser

As this type accepts multiple values (email addresses in my case) I added two users here:

Add-PnPListItem -List $newList -Values @{"User" = "test1@contoso.com","test2@contoso.com"} -ContentTyp Item

If I then try to search for test1@contoso.com and only replace it with test3@contoso.com all the values are replaced, i.e. test2@contoso.com as well:

Get-PnPListItem -List "Test" | Where-Object {$_.FieldValues.User.Email -eq "test1@contoso.com} | Set-PnPListItem -List "Test"  -Values @{"User" = "test3@contoso.com"}

The result is that the cell doesn't contain two values (test1@contoso.com, test2@contoso.com) but only test3@contoso.com.

Is there a way to only replace one value instead of all of them?

Thanks a lot in advance.

0

Set-PnPListItem command is used to update a list item, if you want the updated column contains multiple values, you need to set multiple values in the Set-PnPListItem command.

  • Thanks. So I actually wanted more like a replace option for one value within a cell that contains multiple values instead of updating the whole cell. I guess that`s not possible as I have not found any other option than to update the whole cell. – colonel_claypoo Sep 11 '17 at 11:09
  • yes, there is no way to replace one value of multiple user column, you need to update the entire column's values. – Kally_MSFT Sep 13 '17 at 9:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.