jzrobbie
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.
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
Try changing $_.displayname to simply $PSItem
I believe there's a common property between those two cmdlets, so it should work...
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()}}
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.
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
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
@MAS
It worked!!!
Sort-Object dose the job.
Can you tell me why we need to sort the output before piping to get-mailboxstatistics?
It worked!!!
Sort-Object dose the job.
Can you tell me why we need to sort the output before piping to get-mailboxstatistics?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you guys for the help, problem solved.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
https://gallery.technet.microsoft.com/exchange/Email-statistics-including-e9cb1b26