Monday, June 16, 2014

Simple Code for Reporting Mailbox Size for a Single Database

Hi Folks,

This is quite simple PowerShell code that I want to share with you today.

It pipelines mailboxes from a DB (let's call it DB03) and reports their names, total items and total deleted items sizes in megabytes (as for small mailboxes reporting in gigabytes is not always accurate) along with the total items and total deleted items numbers and nicely imports all data to CSV file that can be then processed in MS Excel.

Please note that plain use of TotalItemSize and TotalDeletedItemSize outputs like this:



Therefore I had to convert information about the mailbox size and deleted item size so that it can be then processed in Excel. I had to use the following expressions to achieve this: @{N="MailboxSize MB";E={$_.TotalItemSize.Value.ToMB()}} and @{N="DeletedItem MB";E=$_.TotalDeletedItemSize.Value.ToMB()}}

All this results in the following script:

Get-Mailbox -Database DB03 |Get-MailboxStatistics |select DisplayName,@{N="MailboxSize MB";E={$_.TotalItemSize.Value.ToMB()}},@{N="DeletedItem MB";E=$_.TotalDeletedItemSize.Value.ToMB()}},ItemCount,DeletedItemCount |Export-Csv D:\Scripts\DB03-Mbx-Size.csv

As a result I'm getting a nice output as this one:



Enjoy

No comments:

Post a Comment