Get Sum of Exchange Mailbox Statistics

白昼怎懂夜的黑 提交于 2019-12-22 09:50:13

问题


I'm trying to get the sum of the TotalItemSize for an Exchange database using the command

Get-MailboxStatistics -Database MBX07 | Measure-Object -Sum TotalItemSize

The command works perfectly fine in the Windows PowerShell ISE but if I run it in an Exchange EMS (both are on my local machine) I get errors for every mailbox in the database that say

Measure-Object : Input object "8.518 MB (8,932,049 bytes)" is not numeric.

The output in the ISE where the command works looks like

Count    : 174
Average  : 
Sum      : 203481256406
Maximum  : 
Minimum  : 
Property : TotalItemSize

It's an Exchange 2010 SP1 server running on Windows Server 2008 R2 and I'm running Windows 8.1 64bit

Any help is greatly appreciated


回答1:


This was run from my EMC on my server.

Get-MailboxStatistics -Database MBX07 | ForEach-Object {[Microsoft.Exchange.Data.ByteQuantifiedSize]::Parse($_.TotalItemSize)} | Measure-Object -sum

TotalItemSize is of type Microsoft.Exchange.Data.ByteQuantifiedSize so we use its method Parse to get a value we can put into -sum

More on this here

BONUS

You can try this which will output the Sum in MB

Get-MailboxStatistics -Database MBX07 | ForEach-Object {
     ([Microsoft.Exchange.Data.ByteQuantifiedSize]::Parse($_.TotalItemSize)).ToMb()
     } | Measure-Object -sum



回答2:


Slightly more PowerShell native way, instead of calling a .NET method with ::

Get-Mailbox -Database "DB1" | Get-MailboxStatistics | ForEach-Object { $_.TotalItemSize.Value.ToGb() } | Measure-Object -sum



来源:https://stackoverflow.com/questions/25455581/get-sum-of-exchange-mailbox-statistics

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!