1

I am trying to retrieve the actual username from a lookup column, the closest I got is

$test=(Get-PnPListItem -List $list -Fields Owner -Id 1).FieldValues 

This of course returns the value as Microsoft.SharePoint.Client.FieldUserValue.

Any suggestions?

1 Answer 1

2

I will answer my own question just in case it's useful for others.

First we need to pull the list item:

$listitem=(Get-PnPListItem -List "TestList" -id $itemid).FieldValues

Then pick the column where the user information is stored and get the email back:

$team_lead_email=$listitem["TeamLeader"].Email

If the field has multiple entries we have to loop through the entries:

$users=$listitem["TeamMembers"].Email


foreach ($User in $Users) { 
    Add-PnPUserToGroup -LoginName $User -Identity "$Team Members"
} 

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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