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?

  • 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 Feb 18 at 3:16
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
  • Tried the Value property, gives me the same error as that too doesn't support the subtraction operation – Slartibartfast Feb 18 at 5:26
  • What is the version of Exchange you are working with? – Gert Jan Kraaijeveld Feb 18 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. – Gert Jan Kraaijeveld Feb 18 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/… – Gert Jan Kraaijeveld Feb 18 at 6:21
  • Thanks, I thought there was a better way than to processing as a string using TrimEnd – Slartibartfast Feb 18 at 7:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.