Managing Exchange Online Mailbox Size

Managing mailbox size is a crucial aspect of maintaining a healthy Exchange Online environment. As an Office365 Admin, you can leverage PowerShell to efficiently manage and monitor mailbox sizes. This article provides a step-by-step guide on using PowerShell to manage mailbox sizes, helping you maintain optimal performance and avoid storage issues. Step 1: Connect to Exchange Online Before you can manage mailbox sizes, you need to establish a connection to your Exchange Online service. Open PowerShell as an administrator and run the following command:
Connect-ExchangeOnline
Step 2: Get Mailbox Size To retrieve the current size of a specific mailbox, use the `Get-MailboxStatistics` cmdlet. Replace ‘user@domain.com’ with the mailbox you wish to check:
Get-MailboxStatistics -Identity user@domain.com | Select-Object DisplayName, TotalItemSize
Step 3: Get Mailbox Size for All Users To get the size of all mailboxes in the organization, you can run the following command. This will display each mailbox along with its size:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName, TotalItemSize
Step 4: Set Mailbox Size Limits To set size limits on a user’s mailbox, use the `Set-Mailbox` cmdlet. You can define the warning quota, the send quota, and the send/receive quota. Replace ‘user@domain.com’ with the particular mailbox:
Set-Mailbox -Identity user@domain.com -ProhibitSendQuota 1.5GB -ProhibitSendReceiveQuota 2GB -IssueWarningQuota 1GB
Step 5: Get Mailbox Quota Information To retrieve the quota settings for a specific mailbox, use the `Get-Mailbox` cmdlet. Replace ‘user@domain.com’ with the specific email address:
Get-Mailbox -Identity user@domain.com | Select-Object DisplayName, ProhibitSendQuota, ProhibitSendReceiveQuota, IssueWarningQuota
Step 6: Increase Mailbox Size for Multiple Users If you need to increase the mailbox size limits for multiple users, you can combine PowerShell commands. Here’s an example of increasing the size for all users in a specific department:
Get-Mailbox -Filter "Department -eq 'Sales'" | Set-Mailbox -ProhibitSendQuota 5GB -ProhibitSendReceiveQuota 6GB -IssueWarningQuota 4GB
Step 7: Monitor Mailbox Size Trends To monitor mailbox size trends over time, you can schedule a script to run periodically and log the results. Here is an example script you can modify and schedule in Task Scheduler:
$mailboxes = Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics
foreach ($mailbox in $mailboxes) {
    $size = $mailbox.TotalItemSize.Value.ToString()
    $log = "$($mailbox.DisplayName), $size"
    Add-Content -Path "C:\MailboxSizeLog.txt" -Value $log
}
Step 8: Identify Inactive Mailboxes Inactive mailboxes can consume valuable storage space. To identify mailboxes that haven’t been accessed in a while, use the following command:
Get-MailboxStatistics | Where-Object {$_.LastLogonTime -lt (Get-Date).AddDays(-90)} | Select-Object DisplayName, LastLogonTime
Step 9: Clean Up Deleted Items Users sometimes forget to empty their deleted items folder. You can help manage mailbox size by cleaning up deleted items for all users periodically. Here’s how:
Get-Mailbox -ResultSize Unlimited | Search-Mailbox -SearchQuery 'FolderId:inbox-deleteditems' -DeleteContent
Step 10: Generate a Mailbox Size Report Finally, creating a detailed report of mailbox sizes can help you keep track of usage and make informed decisions. Use this script to generate a report and export it to a CSV file:
$mailboxReport = Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName, TotalItemSize, ItemCount
$mailboxReport | Export-Csv -Path "C:\MailboxSizeReport.csv" -NoTypeInformation
By following these steps, you can effectively manage and monitor mailbox sizes in your Exchange Online environment. PowerShell provides powerful tools for Office365 Admins to automate tasks and maintain control over their organization’s email storage. Happy scripting!

Written by Andrius