I’m using Measure-Object with the -Sum tag in powershell to sum together the result of a number of filesizes in a Exchange mailbox database. The result of this operation is an object which just seems to hold a single integer value.
I need to compare this sum to another sum, but I’m told the "sum" object does not implement "IComparable". So what I really need is to get at that single integer value inside this object returned from the "Measure-Object" command.
Example (for testing):
[PS] >$size1 = Get-MailboxStatistics -Database Some\Exchange\Database | select-object {$.TotalItemSize/1MB} | Measure-Object -Property ‘$.TotalItemSize/1MB’ -Sum | Select Sum
[PS] >$size2 = Get-MailboxStatistics -Database Someother\Exchange\Database | select-object {$.TotalItemSize/1MB} | Measure-Object -Property ‘$.TotalItemSize/1MB’ -Sum | Select Sum
Doesn’t work:
echo ($size1 -lt $size2)
1 Answer