We can find mailbox size of all users by using the office 365 powershell cmdlet Get-MailboxStatistics. The Get-MailboxStatistics cmdlet is used to obtain information about a mailbox, such as the total size of the mailbox, the number of messages it contains, and the mailbox logon activity.
Note: Before proceed, Connect Exchange Online Remote PowerShell.
The below powershell command returns mailbox size and total mail count for the office 365 user ‘Kevin’
Get-MailboxStatistics -Identity 'Kevin' | Select DisplayName,ItemCount,TotalItemSize
Get Mailbox size and usage for all Office 365 users
You can use the powershell cmdlet Get-Mailbox to get all the mailboxes and pipe the results into Get-MailboxStatistics cmdlet to get mailbox size and total message count for all the users.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object -Property @{label=”User”;expression={$_.DisplayName}}, @{label=”Total Messages”;expression= {$_.ItemCount}}, @{label=”Total Size (MB)”;expression={[math]::Round(` ($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}}
Use the below command to sort mailbox list by mailbox size in descending order.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object -Property @{label=”User”;expression={$_.DisplayName}}, @{label=”Total Messages”;expression= {$_.ItemCount}}, @{label=”Total Size (MB)”;expression={[math]::Round(` ($_.TotalItemSize.ToString().Split("(")[1].Split(" ")[0].Replace(",","")/1MB),2)}} | Sort "Total Size (MB)" -Descending
Advertisement