Chat
Ask me anything
Ithy Logo

Uncovering Large Mailboxes in Exchange Online with PowerShell

Mastering PowerShell for Efficient Mailbox Management and Storage Optimization

exchange-online-mailbox-size-report-jo6llgtf
  • Targeted Mailbox Identification: PowerShell cmdlets like Get-Mailbox and Get-MailboxStatistics are essential for pinpointing mailboxes that meet or exceed specific size thresholds, such as 90 GB.
  • Beyond Basic Reporting: While the Microsoft 365 Admin Center offers general usage reports, PowerShell provides granular control and detailed data for comprehensive analysis and custom reporting of mailbox sizes, including shared mailboxes and archives.
  • Proactive Storage Management: Regularly monitoring and reporting on large mailboxes enables administrators to proactively address storage issues, optimize resources, and prevent users from hitting storage limits, ensuring seamless communication.

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.


The Power of PowerShell for Mailbox Analysis

Why PowerShell is Your Go-To for Detailed Mailbox Reporting

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.


Connecting to Exchange Online PowerShell

Establishing Your Connection for Effective Command Execution

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.

Installing the Exchange Online Management Module

If you haven't installed the module, you can do so using the following command:

Install-Module -Name ExchangeOnlineManagement

Connecting to Exchange Online

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.


Identifying Mailboxes Over 90 GB

Crafting the PowerShell Command for Precise Filtering

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.

The Core PowerShell Command

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
PowerShell script output showing mailbox sizes

An example of PowerShell script output detailing mailbox sizes.

Breaking Down the Command

  • 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.

Understanding Mailbox Size Metrics

Delving into TotalItemSize and Related Properties

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.

Mailbox folder report with various statistics

A comprehensive mailbox folder report, including size details.

Key Mailbox Properties for Reporting

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.

Visualizing Mailbox Storage Trends

A Radar Chart Perspective on Mailbox Health

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.


Beyond Basic Reporting: Advanced Scenarios

Exporting to CSV, Identifying Top Offenders, and Monitoring Growth

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.

Exporting to CSV

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.

Identifying the Top N Largest Mailboxes

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
Screenshot of PowerShell showing top mailboxes by size

PowerShell output showcasing the top mailboxes sorted by size.

Monitoring Mailbox Size Growth

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.


Admin Center Alternatives for Mailbox Reporting

Navigating Microsoft 365's Built-in Reporting Features

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.

Microsoft 365 Admin Center Usage Reports

You can access mailbox usage reports directly from the Microsoft 365 admin center:

  1. Go to the Microsoft 365 admin center.
  2. Navigate to Reports > Usage.
  3. Under Email activity, select View More.
  4. From the drop-down list, select Exchange > Mailbox usage.

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.

Microsoft 365 Mailbox Usage Dashboard

The Mailbox Usage Dashboard in the Microsoft 365 Admin Center.

Exchange Admin Center (EAC)

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.


Understanding and Managing Mailbox Quotas

Ensuring Mailbox Health and Preventing Disruptions

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:

  • Communicate with users: Inform users about their mailbox size and encourage them to clean up unnecessary items.
  • Enable Online Archiving: For users with large mailboxes, enabling an online archive can move older emails to a separate, typically much larger, archive mailbox, freeing up space in the primary mailbox. This is a common strategy for "hoarder mailboxes."
  • Increase Mailbox Quota: If justified by business needs and licensing, increase the mailbox quota by assigning a higher-tier license.
  • Identify and Delete Large Items: Use PowerShell to find and delete particularly large items or folders from mailboxes.

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.


Frequently Asked Questions

What is 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.
Can I get a report for shared mailboxes only?
Yes, you can filter for shared mailboxes specifically by adding a -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
How can I automate this report?
You can automate this report by saving the PowerShell script as a .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.
What are the default mailbox size limits in Exchange Online?
The default mailbox size limits in Exchange Online depend on the assigned license. Typically, Exchange Online Plan 1 provides 50 GB of storage, while Exchange Online Plan 2 offers 100 GB. Shared mailboxes are usually 50 GB by default but can be increased to 100 GB with an Exchange Online Plan 2 license.
What if I encounter errors when running the PowerShell commands?
Common errors include not being connected to Exchange Online PowerShell, insufficient permissions, or issues with the installed module. Ensure you have the latest Exchange Online Management module, are connected successfully, and have the necessary administrative roles (e.g., Global Admin or Exchange Admin) to execute the commands. Always run PowerShell as an administrator.

Conclusion

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.


Recommended Further Exploration


References


Last updated May 21, 2025
Ask Ithy AI
Download Article
Delete Article