PowerShell - Exchange - Mailbox Size

Posted on 2011-03-03
Last Modified: 2012-05-11
So I am trying to get a list of my users mailbox size (I just took over here and they dont have a mailbox limit).  the command that I have is:

Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | ft DisplayName,@{label="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}},ItemCount

Everytime I run this command on the EMS I get the following:

Cannot process argument transformation on parameter 'Identity'. Cannot convert value "" to type "Microsoft.Exchange.Con
figuration.Tasks.GeneralMailboxOrMailUserIdParameter". Error: "Parameter values of type Microsoft.Exchange.Configuratio
n.Tasks.GeneralMailboxOrMailUserIdParameter can't be empty. Specify a value, and try again.
Parameter name: identity"
    + CategoryInfo          : InvalidData: (:) [Get-MailboxStatistics], ParameterBindin...mationException
    + FullyQualifiedErrorId : ParameterArgumentTransformationError,Get-MailboxStatistics

So I am thinking somewhere I am not telling the script that I need everyuser - thus the Identity error.

Question by:Travis Hahn
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
LVL 20

Expert Comment

by:Satya Pathak
ID: 35028574
LVL 71

Expert Comment

by:Chris Dent
ID: 35028898

Can you try:
Get-Mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | 
  Select-Object DisplayName, @{name="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, ItemCount

Open in new window

I seem to remember they modified the behaviour of Get-MailboxStatistics a little for Exchange 2010. I swapped in Select-Object for FT (Format-Table) as well, this will allow you to pipe to a CSV file if you wish. e.g.
Get-Mailbox | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | 
  Select-Object DisplayName, @{name="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, ItemCount |
  Export-Csv "YourFile.csv" -NoTypeInformation

Open in new window


Free NetCrunch network monitor licenses!

Only on Experts-Exchange: Sign-up for a free-trial and we'll send you your permanent license!

Here is what you get: 30 Nodes | Unlimited Sensors | No Time Restrictions | Absolutely FREE!

Act now. This offer ends July 14, 2017.


Author Comment

by:Travis Hahn
ID: 35029004
Chris that was PERFECT.  So what I see is that I needed to call the "get-Mailbox" before I could get MailBoxStatistics.

Is that correct?
LVL 71

Accepted Solution

Chris Dent earned 500 total points
ID: 35029030

Yes, indeed.

Exchange 2007 has a default value, so Get-MailboxStatistics on its own is fine. Most of the examples you find kicking around will be for Exchange 2007.

They changed that with 2010, now you need to be specific, or if you want everyone you have to pipe through something else (like Get-Mailbox).

Finally, if you have a lot of users you may need to add "-ResultSize Unlimited". e.g.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | 
  Select-Object DisplayName, @{name="TotalItemSize(MB)";expression={$_.TotalItemSize.Value.ToMB()}}, ItemCount |
  Export-Csv "YourFile.csv" -NoTypeInformation

Open in new window


Author Closing Comment

by:Travis Hahn
ID: 35029075
Thank YOU Chris

Featured Post

Free learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Background Information Recently I have fixed file server permission issues for one of my client. The client has 1800 users and one Windows Server 2008 R2 domain joined file server with 12 TB of data, 250+ shared folders and the folder structure i…
Previously, on our Nano Server Deployment series, we've created a new nano server image and deployed it on a physical server in part 2. Now we will go through configuration.
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…
how to add IIS SMTP to handle application/Scanner relays into office 365.

734 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