How to find mailboxes by size

Posted on Posted in Uncategorized

So you need to find mailboxes that are larger or smaller than a certain size – how do you do it? In this example you need to find mailboxes smaller than an arbitrary number, maybe 450MB

Quite simply by running the following Powershell command:

Get-MailboxDatabase sg1pexhv002\cms2_sg1_mbdb1_nam1 | get-mailboxstatistics | where {$_.totalitemsize -le 450mb}

 

Powershell is really good at automatically converting the 450MB as 450 Mega Bytes and comparing it to "totalitemsize" by by default returns a number in bytes.

 

Finding oversized mailboxes is equally simple:

 

Get-MailboxDatabase sg1pexhv002\cms2_sg1_mbdb1_nam1 | get-mailboxstatistics | where {$_.totalitemsize -ge 450mb}

 

Notice that the only thing I changed what the -le (less than or equal to) switch to the -ge (greater than or equal to) switch. How can you find out what all the switches are?

Get-help About_where

After that you can export to csv, change all the mailbox settings all at once, etc,etc by simply piping the result into another commandlet, e.g.

 

Get-MailboxDatabase sg1pexhv002\cms2_sg1_mbdb1_nam1 | get-mailboxstatistics | where {$_.totalitemsize -ge 450mb} |export-csv c:\report.csv