Convert the Get-MailboxStatistics output from Bytes to MB or GB in Exchange 2007.

November 7, 2007

in Exchange, Microsoft

Exchange 2003 Administrators are used to using the old Exchange Console to view the size of the mailboxes in your Exchange organization.  The Exchange 2007 EMC unfortunately doesn’t have this feature anymore.  Here’s a little PowerShell script that will translate the output of the Get-MailboxStatistics command from Bytes to MB or GB.

For a single user:
Get-MailboxStatistics  |  select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}
Get-MailboxStatistics  |  select-object DisplayName, {$_.TotalItemSize.Value.ToGB()}
Get-MailboxStatistics  |  select-object DisplayName, {$_.TotalItemSize/1.0MB}
Get-MailboxStatistics  |  select-object DisplayName, {$_.TotalItemSize/1.0GB}

To get the script to work for all users just add the “Get-Mailbox” command.

For all users:
Get-Mailbox | Get-MailboxStatistics |  select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}
To export to a csv:
Get-Mailbox | Get-MailboxStatistics |  select-object DisplayName, {$_.TotalItemSize.Value.ToMB()} | export-csv -path "c:\path\filename.csv"

With a little ingenuity you can really get creative on your output.  For example, you could alter the Get-Mailbox command to limit your results to Mailbox Store or Server.  How far will you go?

61,936 views
1 Star2 Stars3 Stars4 Stars5 Stars (4 votes, average: 4.50 out of 5)
Loading...
Rub Ortega May 6, 2010 at 9:48 pm

How can I know the storage limit for each user?

Matt_Wade May 7, 2010 at 7:10 pm

You'll need to use the get-mailbox command.

Get-Mailbox user | select Name,*Quota | ft

This would give you a nice layout on the screen. If you wanted to export to a csv just pipe the command to export-csv as shown above.

To covert to MB you'll need to replace *Quota with the actual fields:

{$_.ProhibitSendQuota.Value.ToMB()}
{$_.ProhibitSendReceiveQuota.Value.ToMB()}
{$_.IssueWarningQuota.Value.ToMB()}

Marion Jenkins Jr. December 29, 2010 at 4:39 pm

Your export to csv command for mailboxstatistics worked great. I spent a lot of time on this before visiting your site. I am glad I discovered your site 🙂

david March 9, 2011 at 6:13 pm

hi,
how to export all users mailbox to a html report?
thanks
david

Allan July 12, 2011 at 11:59 pm

Hi,

This site is very helpful.

Thanks,
Allan

Allan July 13, 2011 at 12:06 am

Hi,

Can someone tell me if there’s an article about transaction logs not purging automatically.
I got this problem with my new employer, they have 28 storage groups with 1 db on each SG.
Only two SGs have no problem with their transaction logs, the rest are all problematic.
Transaction logs are piling on each SG folders except for the two SGs.

Hope you can help me on this.

Thanks and regards,

Allan

Matt July 19, 2011 at 2:29 pm

I can only think of two items: 1) The Databases are not being backed up or the backup is not truncating the logs as it should. 2) Circular Logging is not enabled. This is not recommended as you will not be able to preform incremental restores/backups. I would try addressing your question to the MS Forums at http://social.technet.microsoft.com as you’ll get a much wider audience than you will here.

Mariano September 13, 2011 at 2:03 am

Hello,
this is a very helpfull command, and also website!! Congrats!!

I would like somebody help me:
i mean, i would like to combine the results of get-mailboxstatistics with TotalItemSize.Value to MB, and get-mailbox with name, Issue warningquotas,MaxSendSize, MaxReceiveSend. Sorting the results by name, and export to csv file
I´ve been trying some posibilities but not reach to sucesful results.
My commands :
Get-Mailbox -resultsize unlimited | select Alias, Name, database, IssueWarningQuota, MaxSendSize, MaxReceiveSend
Get-Mailbox | Get-MailboxStatistics | select-object DisplayName, {$_.TotalItemSize.Value.ToMB()}

Could you please help me?
Thanks in advance

Ben Oostdam May 19, 2012 at 2:10 am

Take a look at this article, it might help you out.
http://www.oostdam.info/index.php/sectie-blog/51-scripting/337-exchange-2010-get-mailboxstatistics
Cheers,.. Ben

Andres Pinto April 6, 2016 at 1:35 pm

get-mailbox -resultsize unlimited | Get-MailboxStatistics | ft displayname,@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}}