Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding Which User Has A Specific Email Address

Management With PowerShell

Finding Which User Has A Specific Email Address

by  markdmac  Posted    (Edited  )
markdmac's Exchange 2007 Troubleshooting Tips
By Mark D. MacLachlan, The Spider's Parlor
http://www.thespidersparlor.com


A common scenario in business is you are asked to add an email address to a particular user. You try to do so and receive a message that the address is already in use, but you are not told WHICH user has the mailbox.

Back in the Exchange 2003 days I could find this fairly easily with about 20 lines of vbscript code. Finding the same solution in PowerShell was eluding me.

So after a bunch of reading and research I finally have the solution. This is so much easier in PowerShell since it is only one command. Now if I could just get passed my mental blocks on finding the commands....

The below code will find and report which user mailbox has the email id "searchuser@company.com", so just replace the email address with the address you are searching on.

Code:
(Get-Mailbox | ? {$_.EmailAddresses -match "^smtp:[red]searchuser@company.com[/red]"}).name

In really large organizations you will need to specify to use a larger result set. to do so use the following command.
Code:
(Get-Mailbox -ResultSize Unlimited | ? {$_.EmailAddresses -match "^smtp:[red]searchuser@company.com[/red]"}).name


Happy scripting!
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top