3

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

Martin
  • 503
  • 1
  • 6
  • 20

3 Answers3

2

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
Matt
  • 45,022
  • 8
  • 78
  • 119
1

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

Garrett
  • 181
  • 1
  • 4
0

Useful for large servers, for all databases and in Giga Byte

Get-Mailbox -ResultSet Unlimited | Get-MailboxStatistics | ForEach-Object {
     ([Microsoft.Exchange.Data.ByteQuantifiedSize]::Parse($_.TotalItemSize)).ToGb()
     } | Measure-Object -sum
Shadi Alnamrouti
  • 11,796
  • 4
  • 56
  • 54