Public/Get-MailboxSize.ps1

1
2
3
4
5
6
7
8
9
10
11
12
13
function Get-MailboxSize {
    <#
.SYNOPSIS
Gets all mailboxes and the mailbox sizes. Fixes the built in TotalItemSize property by adding a TotalSizeInBytes field.
#>

    param()

    $Mailbox = Get-Mailbox
    $Statistics = $Mailbox | Get-MailboxStatistics
    $Statistics | Add-Member -MemberType ScriptProperty -Name 'TotalSizeInBytes' -Value { $this.TotalItemSize -replace "(.*\()|,| [a-z]*\)", "" }
    $Statistics

}