Link to home
Start Free TrialLog in
Avatar of jzrobbie
jzrobbieFlag for Australia

asked on

Exchange 2010 get-mailbox and get-mailboxstatistics

Hi,
I am trying to do some auditing to get all mailboxes primary email addresses , aliases and mailbox sizes.
I have run below script and get primary and aliases email addresses, but it does not give me mailbox sizes.
Get-Mailbox -ResultSize Unlimited |Select-Object DisplayName,ServerName,PrimarySmtpAddress, @{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}, @{Name="TotalSize"; Expression={get-mailboxstatistics $_.displayname | Select-object TotalItemSize}} | Export-CSV c:\temp\smtp.csv

Open in new window

Avatar of M A
M A
Flag of United States of America image

Please check my article which will give you name, PrimarySmtpAddress, DatabaseQuotaenabled, TotalItemSize, ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota, DBIssueWarningQuota, DBProhibitSendQuota, DBProhibitSendReceiveQuota
https://gallery.technet.microsoft.com/exchange/Email-statistics-including-e9cb1b26
Try changing $_.displayname to simply $PSItem
I believe there's a common property between those two cmdlets, so it should work...
You can try this if you want to pipe get-mailbox and get-mailboxstatistics together
Get-Mailbox -ResultSize Unlimited | sort-object | Select-Object DisplayName, Alias, PrimarySMTPAddress,EmailAddresses,@{n="MailboxSizeMB";e = {$MBXstat = Get-MailboxStatistics $_.Displayname; $MBXstat.TotalItemSize.Value.ToMB()}}

Open in new window

Avatar of jzrobbie

ASKER

@MAS, Thank you for the script. but How can I export to CSV file without adding multiple headers?
I have modified your script a bit , but it shows the item size is "-", still can't figure out why.

Get-Mailbox -ResultSize Unlimited -server NXT17|
Select-Object DisplayName,ServerName,PrimarySmtpAddress, `
@{Name=“EmailAddresses”;Expression={$_.EmailAddresses |Where-Object {$_.PrefixString -ceq “smtp”} | ForEach-Object {$_.SmtpAddress}}}, `
@{Name="size";Expression={if ((Get-Mailboxstatistics $_.alias).TotalItemSize.Value)`
{(Get-Mailboxstatistics $_.alias).TotalItemSize.Value.ToMB()}else{"-"}}} |
more

Open in new window

@sirbounty

Changed to $PSItem ,it still shows blank output for TotalItemSize column
User generated image
ASKER CERTIFIED SOLUTION
Avatar of M A
M A
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@MAS

It worked!!!

Sort-Object dose the job.

Can you tell me why we need to sort the output before piping to get-mailboxstatistics?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you guys for the help, problem solved.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial