howto obtain email addresses from AD given the user name as domain\id using PowerShell

Mina Kamel 46 Reputation points
2021-02-11T18:12:31.1+00:00

Hello,

how can I obtain the email address for a given user for example user id given in the form domain\ID how can I use this to find there email address using AD.

Thanks for all the help in advance.

Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,183 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 78,151 Reputation points MVP
    2021-02-11T18:43:15.47+00:00

    Maybe this helps (not tested):

    $user = 'domain\peter'
    $SamAccountName = $user.Split('\')[1]
    Get-ADUser -Identity $SamAccountName -Properties EmailAddress
    

    (If the reply was helpful please don't forget to upvote and/or accept as answer, thank you)

    Regards
    Andreas Baumgarten

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful