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        : server1.contoso.com

Thanks in advance guys.
GCTTechsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

SubsunCommented:
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

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
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.



-Praveen
0
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?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Powershell

From novice to tech pro — start learning today.