I am trying to gather mailbox statistics for all mailboxes in our organization, exporting it to an Excel /CSV file. This is the code I came up with /gathered so far:
Get-Mailbox -ResultSize Unlimited |Get-MailboxStatistics | where {$_.ObjectClass -eq “Mailbox”} | Sort-Object TotalItemSize -Descending |FT @{label=”User”;expression={$_.DisplayName}},ServerName,Database,@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}} |Out-File -Append -FilePath C:\Users\Public\Documents\MailboxSize.log
- When using Export-Csv, the file written doesn't contain the requested information /output. It only shows 'gibberish'
- When running above script I am faced with a 'Allowed maximum is 524288000' Powershell message and only (a small) part of the requested data is logged
Can you help me solve the two remarks made?
= = = = = =
This is what I am currently using. It provides me the requested details and output. Although I am looking to further optimize this part, in a larger scheme of things, I am happy with the fact that it is a single-liner command:
Get-Recipient -ResultSize Unlimited |Where {$_.RecipientType –eq “UserMailbox”} |Get-MailboxStatistics | Sort-Object TotalItemSize –Descending |Select-Object @{label=”User”;expression={$_.DisplayName}},@{label=”Total Size (MB)”;expression={$_.TotalItemSize.Value.ToMB()}},@{label=”Items”;expression={$_.ItemCount}},@{label=”Storage Limit”;expression={$_.StorageLimitStatus}} |Export-CSV -NoTypeInformation -Path c:\users\public\documents\$Filename
I do have to adjust the PSSessionConfiguration:
Set-PSSessionConfiguration -name microsoft.powershell -MaximumReceivedObjectSizeMB 800 -Force