terminalb
asked on
Mailbox Report Script Help
Hello,
Exchange 2010 SP2
Server 2008 R2
I commonly run mailbox reports with the intent of exporting a .csv file containing common mailbox properties. I have been using this:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,LastLoggedOnUs erAccount, LastLogonT ime,@{expr ession={$_ .TotalItem Size.Value .ToKB()}}, ItemCount, Organizati onalUnit | Export-Csv MailboxReport.csv -NoTypeInformation
The output shows each mailbox on a separate row with DisplayName being the first column. The main prolbem is it's based on a Get-MailboxStatistics command which doesn't include the WindowsEmailAddress property. I'm thinking a separate command that imports the MailboxStatistics .csv file and appends to it by adding the WindowsEmailAddress would do the trick, but I'm a little fuzzy on some of the finer details:
1. Other than adding a >>, is there any other method of appending to a .csv file?
2. If I do append to the .csv file already created with Get-MailboxStatistics, how can I ensure the WindowsEmailAddress for each mailbox is assigned the correct row for it's respective mailbox?
Exchange 2010 SP2
Server 2008 R2
I commonly run mailbox reports with the intent of exporting a .csv file containing common mailbox properties. I have been using this:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,LastLoggedOnUs
The output shows each mailbox on a separate row with DisplayName being the first column. The main prolbem is it's based on a Get-MailboxStatistics command which doesn't include the WindowsEmailAddress property. I'm thinking a separate command that imports the MailboxStatistics .csv file and appends to it by adding the WindowsEmailAddress would do the trick, but I'm a little fuzzy on some of the finer details:
1. Other than adding a >>, is there any other method of appending to a .csv file?
2. If I do append to the .csv file already created with Get-MailboxStatistics, how can I ensure the WindowsEmailAddress for each mailbox is assigned the correct row for it's respective mailbox?
ASKER
I like the direction you took that, but I ran the script in a test server and received an error:
Select-Object : Key expression has no value.
At line:1 char:114
+ Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object <<<< DisplayName,LastLoggedOnUs erAccount, LastLogonT ime,@{expr ession={$_ .TotalItem Size.Value .ToKB()}}, ItemCount, Organi
zationalUnit,@{expression= (Get-Mailb ox $_.displayname).windowsema iladdress; n="Windows EmailAddre ss"} | Export-Csv MailboxReport.csv -NoTypeInformation
+ CategoryInfo : InvalidArgument: (:) [Select-Object], NotSupportedException
+ FullyQualifiedErrorId : DictionaryKeyMissingValue, Microsoft. PowerShell .Commands. SelectObje ctCommand
Character 176 is just after the expression in your associative array.
Select-Object : Key expression has no value.
At line:1 char:114
+ Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object <<<< DisplayName,LastLoggedOnUs
zationalUnit,@{expression=
+ CategoryInfo : InvalidArgument: (:) [Select-Object], NotSupportedException
+ FullyQualifiedErrorId : DictionaryKeyMissingValue,
Character 176 is just after the expression in your associative array.
ASKER CERTIFIED SOLUTION
membership
Create a free account to see this answer
Signing up is free and takes 30 seconds. No credit card required.
ASKER
Perfect. Apart from adding a space in-between Get-Mailbox and $_.displayname it was right on the money. Thank you very much!
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object DisplayName,LastLoggedOnUs