Get-MailboxStatistics (what am I doing wrong?)

Server: Exchange 2010 SP2

Need some quick help.... what am I doing wrong?

I am trying to run a command via remote powershell to export information from all my Exchange Servers (8 servers in 4 locations), most importantly I want the following data:

DisplayName, TotalItemSize, ItemCount, SamAccountName, UserPrincipalName, RecipientType, and MailboxSize in MB and bytes

I am trying:
PS C:\> Get-MailboxStatistics | Sort-Object TotalItemSize –Descending | select DisplayName,TotalItemSize,ItemCount,SamAccountName,UserPrincipalName,RecipientType | Export-CSV C:\MailboxSizeReport.csv

cmdlet Get-MailboxStatistics at command pipeline position 1
Supply values for the following parameters:
Cannot display the prompt for "Identity" because type "Microsoft.Exchange.Configuration.Tasks.GeneralMailboxOrMailUserIdParameter" cannot be loaded.
    + CategoryInfo          : ResourceUnavailable: (:) [], PromptingException
    + FullyQualifiedErrorId : System.Management.Automation.Host.PromptingException
    + PSComputerName        :

Thanks in advance guys.
Who is Participating?
SubsunConnect With a Mentor Commented:
First Identity is a mandatory parameter for Get-MailboxStatistics. Second Attributes like SamAccountName, UserPrincipalName and RecipientType will not be ther in the output of Get-MailboxStatistics..

Try the following code and see if you get the expected result..
$(Foreach ($mailbox in Get-mailbox -Resultsize Unlimited){
$Stat = $mailbox | Get-MailboxStatistics | Select DisplayName,TotalItemSize,ItemCount
	New-Object PSObject -Property @{
	DisplayName = $mailbox.DisplayName
	TotalItemSize = $Stat.TotalItemSize
	ItemCount = $Stat.ItemCount
	SamAccountName = $mailbox.SamAccountName
	UserPrincipalName = $mailbox.UserPrincipalName
	RecipientType = $mailbox.RecipientType
}) | Sort-Object TotalItemSize –Descending |
Select DisplayName,TotalItemSize,ItemCount,SamAccountName,UserPrincipalName,RecipientType | 
Export-CSV C:\MailboxSizeReport.csv -NTI

Open in new window

GCTTechsAuthor Commented:
Subsun, you replied just ion time... thanks.

Im running the script now... it hasnt failed yet, so thats promising...

We have about 5000 mailboxes spread out over 8 servers so I assume it will take a bit to gather all those details.

Fingers crossed.
Praveen BalanSolution ArchitectCommented:
run below cmdlet to get the complete mailbox statitics,

Get-MailboxServer | Get-MailboxStatistics | select DisplayName,TotalItemSize,ItemCount, | Sort-Object TotalItemSize -Descending | Export-CSV C:\MailboxSizeReport.csv

you can not get the SamAccountName,UserPrincipalName,RecipientType details from statitics cmdlet.

GCTTechsAuthor Commented:
Thanks Praveen, Im still waiting for Subsuns script to complete.

Im not sure your cmdlet would get all the info I need would it?

DisplayName, TotalItemSize, ItemCount, SamAccountName, UserPrincipalName, RecipientType, and MailboxSize in MB and bytes?
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.

All Courses

From novice to tech pro — start learning today.