Get-Mailbox and Get-MailboxStatistics are essential for pinpointing mailboxes that meet or exceed specific size thresholds, such as 90 GB.In the dynamic environment of Microsoft 365, managing mailbox sizes is a critical administrative task. As organizations grow and digital communication expands, individual mailboxes can accumulate significant data, potentially leading to storage limitations and performance issues. Identifying mailboxes that consume a large amount of space, such as 90 GB or more, is crucial for proactive storage management, resource optimization, and ensuring uninterrupted email services for users. PowerShell provides robust and flexible tools to gather this specific information from your Exchange Online tenant efficiently.
While the Microsoft 365 admin center offers basic mailbox usage reports, it often provides limited details, especially when you need to filter for specific size thresholds or generate comprehensive reports for a large number of mailboxes. This is where PowerShell truly shines. PowerShell cmdlets allow for precise querying, filtering, and aggregation of data, enabling administrators to extract specific information about mailbox sizes, item counts, and even last logon times. This level of detail is invaluable for capacity planning, identifying potential issues, and implementing storage management strategies.
The primary cmdlets involved in gathering mailbox size information are Get-Mailbox and Get-MailboxStatistics. The Get-Mailbox cmdlet retrieves a list of mailboxes, including user mailboxes, shared mailboxes, and room mailboxes. Once you have the mailbox objects, you can pipe them to Get-MailboxStatistics, which provides detailed statistics for each mailbox, such as its total item size, item count, and last access time.
Before you can execute any PowerShell commands to retrieve mailbox information, you need to establish a connection to Exchange Online PowerShell. This requires installing the Exchange Online Management module if you haven't already and then authenticating your session.
If you haven't installed the module, you can do so using the following command:
Install-Module -Name ExchangeOnlineManagement
Once the module is installed, you can connect to Exchange Online using the Connect-ExchangeOnline cmdlet. It's recommended to use a User Principal Name (UPN) for authentication, especially when Multi-Factor Authentication (MFA) is enabled.
Connect-ExchangeOnline -UserPrincipalName admin@yourdomain.com
This command will prompt you for your credentials. After successful authentication, your PowerShell session will be connected to Exchange Online, allowing you to run the necessary cmdlets.
To find all mailboxes in your Exchange Online tenant that have 90 GB or more of used space, you need to combine the Get-Mailbox and Get-MailboxStatistics cmdlets and then filter the results based on the TotalItemSize property. The TotalItemSize property is returned by Get-MailboxStatistics and represents the total size of the mailbox, including all items.
Here's the PowerShell command that achieves this:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where-Object {$_.TotalItemSize.Value.ToGBs() -ge 90} | Select-Object DisplayName, PrimarySmtpAddress, @{Name="TotalItemSizeGB"; Expression={$_.TotalItemSize.Value.ToGBs()}}, ItemCount | Sort-Object TotalItemSizeGB -Descending
An example of PowerShell script output detailing mailbox sizes.
Get-Mailbox -ResultSize Unlimited: This part retrieves all mailboxes in your Exchange Online organization. -ResultSize Unlimited ensures that all mailboxes are retrieved, regardless of their number, preventing truncation of results for large tenants.| Get-MailboxStatistics: The pipeline (|) passes the output of Get-Mailbox to Get-MailboxStatistics. This cmdlet then gathers detailed statistics for each mailbox it receives.| Where-Object {$_.TotalItemSize.Value.ToGBs() -ge 90}: This is the filtering step.
Where-Object is used to filter objects based on specified criteria.$_.TotalItemSize accesses the TotalItemSize property of the current mailbox statistic object. This property is an object itself, so we access its Value property..ToGBs() is a method that converts the TotalItemSize (which is typically in bytes or a raw size unit) into gigabytes for easier comparison.-ge 90 is a comparison operator meaning "greater than or equal to 90". This filters for mailboxes with 90 GB or more of used space.| Select-Object DisplayName, PrimarySmtpAddress, @{Name="TotalItemSizeGB"; Expression={$_.TotalItemSize.Value.ToGBs()}}, ItemCount: This selects and formats the desired properties for the output.
DisplayName: The friendly name of the mailbox user.PrimarySmtpAddress: The primary email address of the mailbox.@{Name="TotalItemSizeGB"; Expression={$_.TotalItemSize.Value.ToGBs()}}: This is a calculated property. It creates a new property named "TotalItemSizeGB" and populates it with the mailbox size converted to gigabytes.ItemCount: The total number of items (emails, calendar entries, etc.) in the mailbox.| Sort-Object TotalItemSizeGB -Descending: This sorts the results.
Sort-Object sorts the output.TotalItemSizeGB specifies the property to sort by (the calculated property we created).-Descending sorts the mailboxes from largest to smallest.
When working with mailbox statistics, it's important to understand what the various properties represent. The TotalItemSize is the most direct measure of a mailbox's consumed storage. Other related properties can provide additional context, such as ItemCount, which indicates the number of items. For archival purposes, administrators might also consider ArchiveSize and ArchiveItemCount if online archives are enabled.
A comprehensive mailbox folder report, including size details.
The table below outlines crucial mailbox properties that are frequently used in reporting and their significance:
| Property Name | Description | Relevance for Reporting |
|---|---|---|
DisplayName |
The user-friendly name of the mailbox owner. | Identifies the mailbox for human readability. |
PrimarySmtpAddress |
The primary email address associated with the mailbox. | Unique identifier for the mailbox, useful for scripting and further actions. |
TotalItemSize |
The total size of all items (emails, calendar, contacts, etc.) in the primary mailbox. | Direct measure of storage consumption, critical for quota management. |
ItemCount |
The total number of items in the primary mailbox. | Indicates the volume of content, which can impact performance. |
ArchiveSize |
The total size of the online archive associated with the mailbox. | Important for organizations utilizing archiving to offload primary mailbox data. |
ArchiveItemCount |
The total number of items in the online archive. | Complements ArchiveSize for a complete picture of archived data. |
LastLogonTime |
The last time the mailbox was accessed by the user. | Helps identify inactive mailboxes that might be eligible for archiving or deletion. |
To gain a more intuitive understanding of mailbox health and identify potential storage challenges, visualizing key metrics can be incredibly insightful. A radar chart, for instance, can effectively compare various aspects of mailbox usage across different categories or typical scenarios. Below is a conceptual radar chart that illustrates different aspects of mailbox usage, offering a quick overview of how various factors contribute to overall mailbox management.
This radar chart helps to illustrate the interplay between different aspects of mailbox management. Each spoke represents a critical metric or area of focus for administrators. By plotting conceptual values for different mailbox types or management priorities, we can quickly see where attention is needed. For example, a "Hoarder Mailbox" might score high on "Total Item Size" and "Item Count," indicating a need for intervention. In contrast, a "Well-Managed Mailbox" would show balanced scores across all parameters, indicating efficient storage practices.
The PowerShell command provided is a strong starting point, but its output is limited to the console. For more practical use cases, especially when dealing with a large number of mailboxes, you'll want to export this data to a file format like CSV or HTML for further analysis or reporting.
To export the list of mailboxes over 90 GB to a CSV file, simply append | Export-Csv -Path "C:\Temp\LargeMailboxes.csv" -NoTypeInformation to the end of the command:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Where-Object {$_.TotalItemSize.Value.ToGBs() -ge 90} | Select-Object DisplayName, PrimarySmtpAddress, @{Name="TotalItemSizeGB"; Expression={$_.TotalItemSize.Value.ToGBs()}}, ItemCount | Sort-Object TotalItemSizeGB -Descending | Export-Csv -Path "C:\Temp\LargeMailboxes.csv" -NoTypeInformation
The -NoTypeInformation parameter prevents PowerShell from including type information in the first line of the CSV file, which makes it cleaner for direct use in applications like Excel.
If you're interested in only the top N largest mailboxes (e.g., top 10), you can add | Select-Object -First N before the export:
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Sort-Object TotalItemSize -Descending | Select-Object -First 10 DisplayName, PrimarySmtpAddress, @{Name="TotalItemSizeGB"; Expression={$_.TotalItemSize.Value.ToGBs()}}, ItemCount | Export-Csv -Path "C:\Temp\Top10Mailboxes.csv" -NoTypeInformation
PowerShell output showcasing the top mailboxes sorted by size.
While the above commands give you a snapshot, regular monitoring is key. You can schedule these PowerShell scripts to run periodically (e.g., monthly) and compare the results to track mailbox size growth over time. This helps in identifying trends and proactively managing storage before quotas are exceeded.
For continuous monitoring and reporting, some organizations use third-party tools or more elaborate PowerShell scripts that integrate with scheduling tasks and send automated reports.
While PowerShell offers unparalleled flexibility, Microsoft 365 also provides built-in reporting features within its admin centers. These graphical interfaces can be useful for quick checks or for administrators who prefer a visual approach without diving into scripting.
You can access mailbox usage reports directly from the Microsoft 365 admin center:
This report provides an overview of mailbox usage for user mailboxes, including storage and quota information. You can view trends over 7, 30, 90, or 180 days. While this offers a general overview, it may not allow for precise filtering by specific size thresholds (like 90 GB) directly within the interface for all mailboxes. You can export this data to a CSV file for manual filtering if needed.
The Mailbox Usage Dashboard in the Microsoft 365 Admin Center.
The Exchange Admin Center (EAC) also provides some mailbox details. While it might not offer a consolidated report for all mailboxes with advanced filtering like PowerShell, you can check individual mailbox sizes and some aggregated data. Navigate to Recipients > Mailboxes to see a list of mailboxes. Clicking on a specific mailbox will show its details, including storage usage.
Microsoft 365 provides default mailbox sizes based on the assigned license. For instance, Exchange Online Plan 1 typically offers 50 GB, while Exchange Online Plan 2 offers 100 GB. Shared mailboxes without a license are limited to 50 GB but can be increased to 100 GB by assigning an Exchange Online Plan 2 license. When a mailbox approaches or exceeds its quota, users may receive warnings or be unable to send or receive emails.
Proactive monitoring with PowerShell, as demonstrated, helps identify mailboxes nearing their limits. Once identified, administrators can take several actions:
The following video provides a helpful visual guide on how to manage and potentially increase Microsoft 365 mailbox storage, which is highly relevant to dealing with large mailboxes identified by PowerShell.
A video guide on increasing Microsoft 365 mailbox storage.
Get-MailboxStatistics?Get-MailboxStatistics is a PowerShell cmdlet used in Exchange environments (both on-premises and Exchange Online) to retrieve detailed information about a mailbox, such as its size, the number of items it contains, and the last time it was accessed. It provides crucial data for monitoring and managing mailbox storage.
-RecipientTypeDetails SharedMailbox parameter to your Get-Mailbox command. For example: Get-Mailbox -RecipientTypeDetails SharedMailbox -ResultSize Unlimited | Get-MailboxStatistics | Where-Object {$_.TotalItemSize.Value.ToGBs() -ge 90} | Select-Object DisplayName, PrimarySmtpAddress, @{Name="TotalItemSizeGB"; Expression={$_.TotalItemSize.Value.ToGBs()}} | Sort-Object TotalItemSizeGB -Descending
.ps1 file and then scheduling it to run at regular intervals using Windows Task Scheduler. For Exchange Online, ensure your connection method supports unattended execution, such as certificate-based authentication for the Exchange Online Management module.
Efficiently managing mailbox sizes in an Exchange Online tenant is vital for maintaining smooth operations and preventing storage-related disruptions. While the Microsoft 365 Admin Center offers general oversight, PowerShell provides the precision and depth needed to identify mailboxes that exceed specific size thresholds, such as 90 GB. By leveraging cmdlets like Get-Mailbox and Get-MailboxStatistics, administrators can generate detailed reports, export data for analysis, and proactively implement strategies like online archiving or quota adjustments. This proactive approach ensures optimal performance, resource utilization, and a seamless email experience for all users within the organization.