My context: Sometimes I receive a list of usernames (not CN ), and I need to send emails to these persons.

The question : Is there a simple way on windows to obtain the email from the username ?

migrated from superuser.com Nov 8 at 20:45

This question came from our site for computer enthusiasts and power users.

  • For those who downvoted, please add a commen as the site suggests. – Mehdi Nov 13 at 2:28

(Get-ADUser username -Properties mail).mail

  • That command does not exist by default on Powershell. In a complex environment you don't have enough permissions install software. (BTW your first text was arrogant) – Mehdi Nov 9 at 21:15
  • Then ask your sysadmin to install the tool. – Daniel Nov 11 at 11:08

If you are on Exchange with Outlook you can just copy paste the userid's in the TO/CC/BCC box and hit Ctrl-K.
Else you will need to user powershell as SimonS just mentioned in the comments or do maunal lookups using the Remote Server Administration Tools.

All 3 methods above require that the email is in the normal AD field for that. That may not be the case if your organization uses a non-Exchange solution for mail or has a 3rd party email-provider.

  • The comment has been deleted I guess. For the CTRL+K it does work but only for a few usernames (it seems to be random), in my case I have a lot. If I have a command like you mention I can automate it. – Mehdi Nov 8 at 17:02

Daniel isn't wrong, however if your environment is too "complex" to install RSAT, then you can do it natively in PowerShell

$DirectorySearcher = New-Object DirectoryServices.DirectorySearcher
$DirectorySearcher.Filter = "(&(ObjectClass=user)(Name=$env:USERNAME))"
$Result = $DirectorySearcher.FindOne()
$ADUser = [System.DirectoryServices.DirectoryEntry]$Result.GetDirectoryEntry()
$ADUser.Properties["Mail"]

Your Answer

 

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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