Calculate Exchange & O365 Mailbox Size with Regex

Posted on Posted in Office 365, Powershell

While Get-MailboxStatistics can quickly show total mailbox size the format is terrible and calculated on the fly resulting in something like this:

 

I used to throw multiple split commands at it to get the byte count, and while that worked, it was ugly.¬† I’ve been on a regex kick recently and simplified the solution a bit:

 

Once you get the results back, calculate the sum, divide by your favorite built-in denominator (1KB, 1MB, 1GB), tack on as a noteproperty, and export the results for simple sorting.