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.
HOW TO LIST ALL EXCHANGE ATTRIBUTES OF A USER FROM ACTIVE DIRECTORY :
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*
SCENARIO :
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 🙂
Prateek Singh
Related posts
Categories
Author of Books
Awards
Open Sourced Projects
Author at
Blog Roll
Mike F RobbinsDamien Van Robaeys
Stéphane van Gulick
Kevin Marquette
Adam Bertram
Stephanos Constantinou
Francois-Xavier Cat
Ravikanth Chaganti
Roman Levchenko
Blog Stats
- 1,132,435 People Reached