Select email address from UPN variable?

This topic contains 2 replies, has 2 voices, and was last updated by  Alexanxder Holmeset 3 months, 3 weeks ago.

  • Author
    Posts
  • #73595

    Alexanxder Holmeset
    Participant

    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

    Curtis Smith
    Participant

    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

      Alexanxder Holmeset
      Participant

      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.

You must be logged in to reply to this topic.