Select email address from UPN variable?

Welcome Forums General PowerShell Q&A Select email address from UPN variable?

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 4 months ago.

  • Author
    Posts
  • #73595

    Participant
    Points: 0
    Rank: Member

    How can I select only the email address from the UPN variable, so $useremail -eq $ADUPN is true?

    userPrincipalName
    —————–
    james.bond@contoso.local

    PS C:\Windows\system32> $useremail
    james.bond@contoso.local

    PS C:\Windows\system32> $useremail -eq $ADUPN
    False

  • #73598

    Participant
    Points: 0
    Rank: Member

    Assuming:

    userPrincipalName
    —————–
    james.bond@contoso.local

    is what is shown when you use

    PS C:\Windows\system32> $ADUPN

    Then

    PS C:\Windows\system32> $useremail -eq $ADUPN.userPrincipalName

    By the way, UPN is not an email address, it's a userPrincipalName, which may or may not be the same as the user;s email address depending on how the environment is setup.

    • #73607

      Participant
      Points: 0
      Rank: Member

      Thanks a lot! 🙂

      That did the trick. Know its not the same, migrating from Lotus notes to Office 365 and whant to check that emailadress and UPN is the same, if not flag it to Helpdesk in a email.

      First I thought it was my logical statement that was wrong, until I checked what $ADUPN outputted.

The topic ‘Select email address from UPN variable?’ is closed to new replies.