Skip to content

Get-EXOMailboxStatistics

Exchange Online Management: Gets mailbox statistics for a specified mailbox

#Requires -Version 5.1

[CmdletBinding()]
Param(
    [Parameter(Mandatory = $true)]
    [string]$Identity,
    [switch]$Archive,
    [switch]$IncludeSoftDeletedRecipients,
    [ValidateSet('All','Minimum')]
    [string]$PropertySet = 'Minimum',
    [ValidateSet('*','DisplayName','DeletedItemCount','ItemCount','TotalDeletedItemSize','TotalItemSize','LastLogonTime','LastLogoffTime','SystemMessageSizeWarningQuota')]
    [string[]]$Properties = @('DisplayName','DeletedItemCount','ItemCount','TotalDeletedItemSize','TotalItemSize')
)

Process {
    try {
        if ($Properties -contains '*') {
            $Properties = @('*')
        }

        [hashtable]$cmdArgs = @{'ErrorAction' = 'Stop'; 'Identity' = $Identity; 'Archive' = $Archive; 'PropertySet' = $PropertySet; 'IncludeSoftDeletedRecipients' = $IncludeSoftDeletedRecipients}

        $result = Get-EXOMailboxStatistics @cmdArgs | Select-Object $Properties
        if ($null -eq $result -or $result.Count -eq 0) {
            Write-Output "No mailbox statistics found"
            return
        }
        foreach ($item in $result) {
            $item | Add-Member -NotePropertyName Timestamp -NotePropertyValue (Get-Date -Format "yyyy-MM-dd HH:mm:ss") -PassThru -Force
        }
    }
    catch { throw }
}

Name, Alias or SamAccountName of the mailbox

Off

Return mailbox statistics for the archive mailbox associated with the specified mailbox

Off

Include soft-deleted mailboxes in the results

Logical grouping of properties to retrieve

List of properties to expand. Use * for all properties

An interactive directory of PowerShell scripts.