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"
} 

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.