Finding Email of Logged On User

by Feb 8, 2012

In an Active Directory environment, PowerShell can easily find the currently logged on user and retrieve AD information about that user, for example, his or her email address:

$searcher = [adsisearcher]"(samaccountname=$env:username)"
$searcher.FindOne().Properties.mail

A logon script could then process this information.

Twitter This Tip! ReTweet this Tip!