Get/convert size from exchange mailbox

Welcome Forums General PowerShell Q&A Get/convert size from exchange mailbox

Viewing 5 reply threads
  • Author
    Posts
    • #284827
      Participant
      Topics: 6
      Replies: 4
      Points: 64
      Rank: Member

      Hello all,

      if I look for the quota limits in exchange the result is something like this:

      IssueWarning : 1 GB (1,073,741,824 bytes)
      ProhibitSend : 1.5 GB (1,610,612,736 bytes)
      ProhibitSendReceive : 2 GB (2,147,483,648 bytes)
      TotalItemSize : 86.13 MB (90,314,712 bytes)

      with this it is harder to calculate because it has MB, GB, bytes comma in the output. How i can get a real number? Only bytes  what is displayed for example? Then i can convert it in an other unit i what i need.

      for example:

      1 GB (1,073,741,824 bytes) –> should be 1073741824
      1.5 GB (1,610,612,736 bytes) –> should be 1610612736
      2 GB (2,147,483,648 bytes) –> should be 2147483648
      86.13 MB (90,314,712 bytes) –> should be 90314712

       

      The code i have at the moment:

      Thanks

    • #284860
      Participant
      Topics: 5
      Replies: 252
      Points: 999
      Helping Hand
      Rank: Major Contributor

      I don’t have an exchange environment to test.  What data type are those object properties (strings, int)?  The code you posted assigns all output to variables.  I’m assuming you are displaying the $props collection and that is where you get a display you don’t want.  If those properties are strings, you’ll have to parse them which is a little more complicated, but if they are a number data type, you just need to format them as you like with the ToString() method.  Here are a couple examples:

      Formatting Numbers:

      Recommend reviewing format types in .NET

      https://docs.microsoft.com/en-us/dotnet/standard/base-types/formatting-types

      Parsing String with a simple conversion function:

    • #284881
      Participant
      Topics: 6
      Replies: 4
      Points: 64
      Rank: Member

      Here is what i get with get-mailbox | get-member
      TypeName: Microsoft.Exchange.Data.Directory.Management.Mailbox

      Name: IssueWarningQuota
      MemberType: Property
      Definition: Microsoft.Exchange.Data.Unlimited[Microsoft.Exchange.Data.ByteQuantifiedSize] IssueWarningQuota {get;set;}

    • #285055
      Participant
      Topics: 9
      Replies: 706
      Points: 2,837
      Helping Hand
      Rank: Community Hero

      Take a closer look at the output of Get-Member

      Now if you inspect the value property

      Now we can simply use the ToBytes() method

      • This reply was modified 1 week, 2 days ago by Doug Maurer.
    • #285070
      Participant
      Topics: 6
      Replies: 4
      Points: 64
      Rank: Member

      yes, i know. I spend a lot of time to try the implemention in my script. but wihout luck. is there no other way to replace everything outside the bracket, then remove the brackets and commas?

    • #285109
      Participant
      Topics: 9
      Replies: 706
      Points: 2,837
      Helping Hand
      Rank: Community Hero

      ToBytes() outputs just the numbers in the parenthesis. Exactly what you are asking for.

Viewing 5 reply threads
  • You must be logged in to reply to this topic.