Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

PowerShell - Exchange - Mailbox Size

Posted on 2011-03-03
6
Medium Priority
?
2,041 Views
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.

Help...
0
Comment
Question by:Travis Hahn
  • 2
  • 2
  • 2
6 Comments
 
LVL 20

Expert Comment

by:Satya Pathak
ID: 35028574
0
 
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

HTH

Chris
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 

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?
0
 
LVL 71

Accepted Solution

by:
Chris Dent earned 2000 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

Chris
0
 

Author Closing Comment

by:Travis Hahn
ID: 35029075
Thank YOU Chris
0

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

How to effectively resolve the number one email related issue received by helpdesks.
There can be many situations demanding the conversion of Outlook OST files to PST format and as such, there is no shortage of automated tools to perform this conversion. However, what makes Stellar OST to PST converter stand above the rest? Let us e…
This video discusses moving either the default database or any database to a new volume.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…

927 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