PowerShell : Retrieving Exchange attributes from Active Directory

No more Logging to Exchange Servers for Quick basic reporting tasks ! 🙂  and don’t even think of loading Exchange Modules 😛

For the basic reporting like Database Names and Home Mailbox Server where the user mailbox is sitting, you can simply query Active directory and get the information.


Just type the below cmdlet and hit enter in your powershell console which will populate all attributes that are synced to AD from Exchange. Just make sure you have imported the AD Module.

Get-AdUser Username -Properties * | Select *MSExch*



Lets just suppose I’ve a list of user and I want to query on which Databases these User’s have their Mailboxes sitting and what are the Servers on which these Databases are mounted.

Run the following scriptlet and here you go 🙂 ..! All your attributes are fetched into your console from Active Directory itself.

'Rohit','Prateek','Sumit','Ankit' | %{ Get-ADUser  -Filter {name -eq $_} -Properties *} | ft Name, @{name='Exchange DB';expression={(($_.HomeMDB).split(',')[0]).split('=')[1]}} ,@{name='Exchange HomeServer';expression={($_.msExchHomeServerName -split 'Servers/cn=')[1]}} -AutoSize


NOTE  :   In most of the organizations AD users have 100+ attributes assigned to them, this is the reason Get-Aduser Cmdlet don’t fetch all attributes by default. But in above image we used the -Property switch with (*) asterisk which could lead to bad performance of the script for large number of users queried. Hence it would be wise to use something like –

‘Rohit’,’Prateek’,’Sumit’,’Ankit’ | %{ Get-ADUser  -Filter {name -eq $_} -Properties HomeDB, msExchHomeServerName} | FT Name, HomeDB, msExchHomeServerName

Well just a small trick, I was not aware of it before today so thought of sharing with you guys.

Thanks for stopping by, Happy Reading Folks 🙂


One thought on “PowerShell : Retrieving Exchange attributes from Active Directory

  1. Nice, but I was wondering how you would go about finding Exchange attributes that are hidden, rather than obvious like these.

    For example, I have been trying to find out how to see which junk mail level our users have set for themselves. Seeing if it is on or off is obviously simple, but it’s damn hard to figure out what level they have set…


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s