I am trying to get the user Email through a LookUpField. When I try to "Write-Host the Email", the screen is blank. There is no errors and nothing. What is wrong with my code? Any help is much appreciated.

    ForEach ($ListItem in $ListItems){

    $lookUpField = $ListItem["uQmsResponsible"] -as [Microsoft.SharePoint.Client.FieldLookupValue]       
    $user = $Web.EnsureUser($lookUpField.LookupValue.DisplayName);
    Write-Host $user.Email -ForegroundColor Cyan



Picture of the listSettings(columns) for the list "Roller" that the LookupField "uQmsResponsible" is referencing : enter image description here

Picture of what Lookupfield returns:

enter image description here

  • Can you debug it in the ISE? Does the $user variable have any value at all? Feb 13, 2018 at 14:04
  • I have never debugged in ISE. Ill check it out right now. Any tips you can give me about ISE while I read up on it?
    – AllramEst
    Feb 13, 2018 at 14:07
  • Is there value present in $lookUpField.LookupValue.DisplayName ? What's the value ? Can you try write host on that ? Feb 13, 2018 at 14:53
  • Ran the code in ISE . $user does not have a value. I also realized I have to expand my search for email in the query. The returned values are the Id of a Role that the User has been given. The lists and all the data was already there when I started working on this project. I must have missed that the user Id is not in the LookUpField. Is there a way to retrive it with expand query?
    – AllramEst
    Feb 13, 2018 at 14:56
  • can you share the query that you are using ? Also, what are you "looking" up to ? Is it a text column or something else ? Feb 13, 2018 at 15:17

1 Answer 1


Judging by the name of your column (uQmsResponsible) I guess it is of type "Person or Group". If that is the case, you should not cast your variable to FieldLookupValue, but to FieldUserValue. You could try with this code:

ForEach ($ListItem in $ListItems)
    $lookUpField = $ListItem["uQmsResponsible"] -as [Microsoft.SharePoint.Client.FieldUserValue]
    Write-Host $lookUpField.Email -ForegroundColor Cyan
  • I dug around a bit in the lists and found that the LookupField "uQmsResponsible" contains a Id for an item in another list. in that list there is an coulmn named Email(textField). i upadated the question. How would I do to fetch the email now?
    – AllramEst
    Feb 13, 2018 at 18:20

Your Answer

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

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