exchange 2007 mailbox size

Posted on 2011-09-02
Medium Priority
Last Modified: 2012-05-12
I am trying to get a report that will list all the mailboxes that are less than 10 GB.  I've used the following command but is gives me a lot of information that I do not need and it lists them by Byte size not GB.

get-mailbox |get-mailboxstatistics | export-csv test.csv| sort-object totalitemsize -descending |ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

Question by:annayeg
LVL 23

Expert Comment

by:Suliman Abu Kharroub
ID: 36476764
You ccan use this :

Get-MailboxStatistics | export-csv test.csv | where {$_.ObjectClass -eq "Mailbox"} | Sort-Object TotalItemSize -Descending | ft DisplayName,TotalItemSiza,ItemCount,StorageLimitStatus

and arrange them using excel  to remove mailboxes larger then 10 GB

Expert Comment

ID: 36477643
I agree with Suliman.

For more details on powershell commands
Go get it at http://go.microsoft.com/?linkid=5719336
LVL 49

Accepted Solution

Akhater earned 2000 total points
ID: 36477651
the below code will do what you want and will show the output in GB

in the line "$mbxSize -lt 10" replace the 10 by any number if you want another threshold in GB

$mbxs = get-mailbox -resultsize unlimited

$all = @()

foreach ($mbx in $mbxs){

  $mbxStat = get-MailboxStatistics -identity $mbx

  $mbxSize = $mbxStat.TotalItemSize.Value.toGB()
  if ($mbxSize -lt 10){
     $out = new-object psobject 

     $out | add-member noteproperty Identity $mbx.name
     $out | add-member noteproperty Database $mbx.database
     $out | add-member noteproperty MailboxSize $mbxSize

     $all += $out


$all = $all | Sort-Object MailboxSize -Descending

$all | export-csv c:\list.csv

Open in new window


Author Comment

ID: 36490475
Hi guys,

I tried pasting the above code in a notepad and rename it mailboxsize.ps2, but when I run it from EMS it opens up the code.
Is there anything that I need to paste in the script?

LVL 49

Expert Comment

ID: 36491433
it should be .ps1 and not .ps2

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

The Windows Firewall provides an important layer of protection and a rich interface to configure it. Unfortunately, it lacks item level filtering. This article details my process of implementing firewall-as-code to reduce GPO bloat.
A method of moving multiple mailboxes (in bulk) to another database in an Exchange 2010/2013/2016 environment...
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

587 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question