Command line active directory query email address for username
On Windows XP in an Active directory environment - what is the easiest way for me to query a user's email address from AD given their username on the command line.
(Assuming I know where it is kept normally in tree).
(I know about net user loginname /domain but I just want the email address element back.)
Solution 1:
dsquery user -name "user name"|dsget user -samid -email -display
Solution 2:
dsquery user -name "Firstname Lastname" | dsget user -email
Solution 3:
If the email that you want is also the User Principal Name, you can get it with
whoami /upn
However, this only works to get the email of the current user, not any user as the question originally postulated.