How to Get Shared Mailbox Size in M365 with PowerShell

Managing shared mailboxes in Microsoft 365 (M365) is a critical task for IT administrators, particularly after a migration. Monitoring shared mailbox sizes ensures compliance with Microsoft’s storage limits and avoids service disruptions. Shared mailboxes in Microsoft 365 come with a 50 GB storage limit if they are unlicensed. Once the limit is exceeded, the mailbox cannot send or receive emails unless a license is assigned. This guide provides step-by-step instructions to check shared mailbox sizes using PowerShell and addresses how to manage oversized mailboxes effectively.
Why Monitor Shared Mailbox Sizes?
Monitoring shared mailbox sizes in M365 helps to:
- Prevent Service Disruption: Ensure mailboxes stay within the storage limit.
- Optimize Resources: Identify mailboxes that require a license.
- Maintain Efficiency: Avoid email send/receive issues.
- Plan for Growth: Anticipate and address future storage needs.
Prerequisites for Using PowerShell with Exchange Online
Before retrieving shared mailbox sizes, ensure you:
- Have administrative privileges in M365.
- Install the Exchange Online Management module for PowerShell.
- Connect to Exchange Online using the steps below.
Step-by-Step Guide to Retrieve Shared Mailbox Sizes
Step 1: Install the Exchange Online PowerShell Module
If the module is not already installed, run the following command in PowerShell:
Install-Module -Name ExchangeOnlineManagement
Step 2: Connect to Exchange Online
1. Open PowerShell as an administrator.
2. Connect to Exchange Online:
Connect-ExchangeOnline -UserPrincipalName <your-admin-username>
3. Authenticate using your credentials.
Step 3: Retrieve Shared Mailbox Details
To list all shared mailboxes, use:
Get-Mailbox -RecipientTypeDetails SharedMailbox
This command provides an overview of shared mailboxes in your tenant.
Step 4: Get Shared Mailbox Sizes
Combine the Get-Mailbox and Get-MailboxStatistics cmdlets to fetch mailbox sizes:
Get-Mailbox -RecipientTypeDetails SharedMailbox | ForEach-Object { $mailbox = $_ $stats = Get-MailboxStatistics -Identity $mailbox.Identity [PSCustomObject]@{ DisplayName = $mailbox.DisplayName PrimarySMTPAddress = $mailbox.PrimarySmtpAddress TotalItemSize = $stats.TotalItemSize.Value.ToString() ItemCount = $stats.ItemCount } } | Format-Table -AutoSize
This command outputs details such as:
- Mailbox display name
- Primary SMTP address
- Total size of the mailbox
- Number of items in the mailbox
Step 5: Identify Large Shared Mailboxes
To locate mailboxes exceeding a specific size (e.g., 40 GB), run:
Get-Mailbox -RecipientTypeDetails SharedMailbox | ForEach-Object { $mailbox = $_ $stats = Get-MailboxStatistics -Identity $mailbox.Identity if ($stats.TotalItemSize.Value.ToGB() -gt 40) { [PSCustomObject]@{ DisplayName = $mailbox.DisplayName SizeInGB = $stats.TotalItemSize.Value.ToGB() } } } | Format-Table -AutoSize
This helps identify mailboxes approaching the 50 GB limit.
Step 6: Manage Oversized Mailboxes
If a shared mailbox exceeds the 50 GB limit, you need to:
1. Assign a License: Use the Microsoft 365 Admin Center or PowerShell to assign a license to the mailbox.
- Example in PowerShell:
Set-MsolUserLicense -UserPrincipalName <MailboxIdentity> -AddLicenses "<LicenseName>"
2. Convert to a Regular Mailbox (if necessary):
Set-Mailbox -Identity <MailboxIdentity> -Type Regular
Common Issues and Solutions
Issue 1: PowerShell Connection Errors
- Ensure the Exchange Online Management module is installed.
- Verify internet connectivity.
- Use updated PowerShell credentials if authentication fails.
Issue 2: Missing Mailbox Data
- Confirm the mailbox identity is correct.
- Use the
Get-Mailboxcommand to verify the shared mailbox exists.
Issue 3: Mailbox Exceeds 50 GB
- Assign a license to enable sending/receiving emails.
- Archive old emails to reduce the mailbox size.
Conclusion
Monitoring shared mailbox sizes in Microsoft 365 is essential to maintain uninterrupted service and ensure compliance with storage limits. PowerShell provides an efficient and powerful way to retrieve mailbox statistics and manage oversized mailboxes. By following these steps, IT administrators can proactively address storage issues and streamline mailbox management.
For expert assistance with managing your Microsoft 365 environment, consider partnering with Medha Cloud. With extensive experience in M365 administration and cloud solutions, Medha Cloud ensures:
- Efficient Resource Management: Optimize your shared mailbox usage.
- Seamless Support: Resolve issues quickly with expert guidance.
- Tailored Solutions: Get strategies customized for your organization’s needs.
Contact Medha Cloud today to simplify your Microsoft 365 management and enhance productivity.
Reach us at:
- India: +91 93536 44646
- US: +1 646 775 2855
- Website: www.medhacloud.com
- Email: info@medhacloud.com