So I recently wanted to create a report to show us who was using up the most space on our mailbox servers, previous administrators had either done away for limits for mailboxes or had set them to be very very generous and our users weren’t really the ones to either keep their mailbox tidy or archive items away.
I knew the quick and easy solution would be powershell and then getting the output to either a CSV file or HTML. So a bit of a look around TechNet for Get-MailboxStatistics got me the commands I needed, but what else could I select out of that. After a bit more digging I found a list on MSDN for MailboxStatistics members which allowed me to extract exactly what I was after. After putting all that together, I cam up with the following
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, TotalItemSize,ItemCount,Database,LastLogonTime,LastLoggedOnUserAccount | Sort TotalItemSize -Descending | ConvertTo-Html -Title "Mailbox Stats"| Out-file "C:\MailboxStatistics.html"
That gave me a nice HTML page output, you could easily improve on this with colours depending on outputs from StorageLimitStatus or LastLogonTime where we found that some mailboxes hadn’t even been used.
Thanks. Worked for me except the LastLoggedOnUserAccount part. I will sort it out though.