How to fetch email address from AD given users ID

Mina Kamel 46 Reputation points
2021-02-15T14:13:28.707+00:00

Hello,

is there a way that I can obtain the email address from given user in the form of domain\ID from AD using powershell.

thanks for all the help.

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,462 questions
0 comments No comments
{count} votes

Accepted answer
  1. Andreas Baumgarten 104K Reputation points MVP
    2021-02-15T14:35:34.397+00:00

    Hi @Mina Kamel ,

    I answered your question already here: https://learn.microsoft.com/en-us/answers/questions/269615/howto-obtain-email-addresses-from-ad-given-the-use.html
    Hope 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

    0 comments No comments

0 additional answers

Sort by: Most helpful