Category Archives: Exchange

Exchange Powershell 1/18/2016

I was tasked with the old “give me a list of all the active users by office and their mailbox stats”. Easy enough, but I’m a bad admin (falling on the sword for those who came before me and also those who sit next to me – you’re welcome and you owe me a beer.), so I don’t really have all of this broken down by office OU. What I DO have is a distribution group for each office which reflects current staffers so here’s how I did it:

get-distributiongroupmember ‘fake list’ |get-mailboxstatistics |export-csv c:\fakestats.csv

 

You can actually do a lot with get-mailboxdistributiongroupmember.

For example, you can grab just their email address and mailbox size and send it to your csv (or show it on screen by dropping the |export-csv bit)

example:

get-distributiongroupmember ‘fake list |select primarysmtpaddress, totalitemsize |fl c:\fakestats1.xls

 

BUT totalitemsize always returns blank (which is why I just used the original csv to hand in as my work and called it a day.) However, if you know anything about me, it became a personal challenge to actually do it the “right way” or better documented way or whatever you want to call it for the next time somebody calls on me for such an annoying list of information.  So, in the spirit of stealing with pride, I found a nice script and modified it to match the fact that I want to return info on a distribution list.

get-distributiongroupmember ‘chicago staff’ | get-mailboxstatistics |add-member -membertype scriptproperty -name totalitemsizeinMB -Value {$this.totalitemsize.value.ToMB()} -passthru | format-table displayname,totalitem* |out-file c:\fun.xls