1

I can get the size of a mailbox using Get-MailboxStatistics. How do I find the difference between two mailbox sizes using Powershell?

I tried:

(Get-MailboxStatistics FordPrefect).totalitemsize - (Get-MailboxStatistics ArthurDent).totalitemsize

which results in the error:

Method invocation failed because [System.ManagementAutomation.PSObject] doesn't contain method named 'op_Subtraction'

which is kinda correct as the totalitemsize object does not have the subtraction method/member. How do I then proceed further with the operation?

1
  • If you want to get all users information, you could use the following command to export to a csv file: Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | ft DisplayName,TotalItemSize | out-file c:\user.csv
    – Shaw Lu
    Feb 18, 2019 at 3:16

1 Answer 1

3

TotalItemSize is not a number, the property has two members:

[PS] C:\Windows\system32>(Get-MailboxStatistics administrator).totalitemsize

IsUnlimited Value
----------- -----
      False 690.4 KB (706,925 bytes) 

This should work:

(Get-MailboxStatistics FordPrefect).totalitemsize.Value - (Get-MailboxStatistics ArthurDent).totalitemsize.Value
6
  • Tried the Value property, gives me the same error as that too doesn't support the subtraction operation Feb 18, 2019 at 5:26
  • What is the version of Exchange you are working with? Feb 18, 2019 at 5:47
  • 1
    Oh, it's Exchange 2013 I see now. My answer is based on Exchange 2016. I do not have 2013 available here. In 2010 things are different. I'll test it in that version, maybe 2013 is the same as 2010 in this matter. Feb 18, 2019 at 5:57
  • 1
    If you run your script (implicit) remotely that is probably the cause of your problems. Have a look at this thread: stackoverflow.com/questions/3156368/… Feb 18, 2019 at 6:21
  • Thanks, I thought there was a better way than to processing as a string using TrimEnd Feb 18, 2019 at 7:13

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .