2.169 GB (2,329,318,152 bytes)When you're trying to use Excel to get an average, this isn't going to work. Instead you need to get that value as an integer. To do this, you need to create your own property for the object with an integer value.
The TotalItemSize property from Get-MailboxStatistics is more complex than it appears. When you use Get-Member to look at the TotalItemSize property returned by Get-MailboxStatistics, it actually contains an IsUnlimited property and a Value property. The Value property has the size of the mailbox.
If you do a Get-Member on the Value property, you can see that there are methods to convert the value to an integer. For example:
(Get-MailboxStatistics Bob).TotalItemSize.Value.ToMB()To create a new property with the correct value as an integer, you use the Add-Member cmdlet. A complete 3 command example that gets all mailboxes and exports the size to csv is below:
$mbx = Get-Mailbox -Resultsize Unlimited | Get-MailboxStatisticsLine 1 gets the mailboxes and their statistics. Line 2 adds the property. Line 3 exports the mailbox name and size to a csv file.
$mbx | Add-Member -MemberType ScriptProperty -Name MbxSizeInMB -Value {$this.TotalItemSize.Value.ToMB()}
$mbx | Select-Object DisplayName,MbxSizeInMB | Export-Csv MailboxSize.csv
No comments:
Post a Comment