OK, so I had some fun making a Powergui Powerpack for Exchange 2003, but its probably about time I wrote about how to do this natively in Powershell.
There is a lot of information you can get out of Exchange 2003 using WMI. Yikes, you might say if you previously thought about doing that with VBScript; however, with Powershell its easy!
We simply use the Get-WMIObject cmdlet, use the ExchangeV2 namespace and Exchange_Mailbox class and connect to the Exchange Server in question.
(You can find all about the Exchange_Mailbox class over on MSDN. Sysadmins amongst you might think MSDN is only for developers, but the Exchange WMI pages are pretty straightforward and all contain a very nice example in VBScript where you can figure most stuff out which is available to you.)
This will return you all the mailbox objects on that server. We then use some basic sorting and selecting to present the info nicely.
Get-WMIObject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ExchangeServerName | sort-object MailboxDisplayName | format-table MailboxDisplayName,Servername,StorageGroupName,StoreName,Size
Cool. I have used it to get a list of all users mailbox consumption on an Exchange 2003 server that was out of reach.
ReplyDeleteI only needed the user and size so this is what I used:
Get-WMIObject -namespace root\MicrosoftExchangeV2 -class Exchange_Mailbox -computer ServerName | Sort-Object Siz
e -Descending | format-table MailboxDisplayName,Size
I was wondering, is there a way to get the username instead of the displayname?
Thanks for a great script.
Kasper
You would need to also pull the LegacyDN attribute, and then leverage (or pipe) that to a Get-Mailbox or Get-ADUser command to pull other attributes, like UserName.
ReplyDeleteYou would need to also pull the LegacyDN attribute, and then leverage (or pipe) that to a Get-Mailbox or Get-ADUser command to pull other attributes, like UserName.
ReplyDelete