get mailbox sizes office 365 powershell

Get Office 365 Mailbox Sizes Fast with PowerShell Script

By Anthony Brown
AD

Get Mailbox Sizes in Office 365 using PowerShell

Managing and monitoring mailbox sizes is a crucial task in any organization, especially in a cloud-based environment like Office 365. PowerShell provides an efficient way to retrieve mailbox sizes, helping administrators identify large mailboxes and take necessary actions. This guide will walk you through the process of getting mailbox sizes in Office 365 using PowerShell.

Prerequisites

Before you begin, ensure you have the following:

  • Office 365 admin account with appropriate permissions
  • PowerShell 5.0 or later installed on your local machine
  • Remote PowerShell module for Exchange Online installed

Connect to Exchange Online PowerShell

To connect to Exchange Online PowerShell, follow these steps:

AD
Resource Center: Budget Mailboxes
Resource Center: Budget Mailboxes
Excel Mailing Labels Without Word Mail Merge
Excel Mailing Labels Without Word Mail Merge
I ran one PowerShell command and reclaimed space from a Windows folder nobody explains
I ran one PowerShell command and reclaimed space from a Windows folder nobody explains
  1. Open PowerShell as an administrator.
  2. Run the following command to import the Exchange Online PowerShell V2 module:
$UserCredential = Get-Credential
$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri https://outlook.office365.com/powershell-liveid/ -Credential $UserCredential -Authentication Basic -AllowRedirection
  1. Import the remote PowerShell session:
Import-PSSession $Session -AllowClobber

Get Mailbox Sizes

Now that you're connected to Exchange Online PowerShell, you can retrieve mailbox sizes using the Get-MailboxStatistics cmdlet. Here's how:

  1. Run the following command to get mailbox sizes:
Get-MailboxStatistics | Select-Object DisplayName, TotalItemSize, ItemCount

This command will display the display name, total item size, and item count for each mailbox.

How to Create Rule in Outlook to move emails to New folder
How to Create Rule in Outlook to move emails to New folder
Simple MBOX to PST Converter – Convert MBOX Files in Minutes
Simple MBOX to PST Converter – Convert MBOX Files in Minutes
Email archiving software MailStore Home 10.1 is out - gHacks Tech News
Email archiving software MailStore Home 10.1 is out - gHacks Tech News

Filter Large Mailboxes

To filter and display only large mailboxes, you can pipe the output to the Where-Object cmdlet. Here's an example that displays mailboxes larger than 50GB:

Get-MailboxStatistics | Where-Object { $_.TotalItemSize -gt 50GB } | Select-Object DisplayName, TotalItemSize, ItemCount

Export Mailbox Sizes to CSV

To export the mailbox sizes to a CSV file for further analysis or reporting, use the Export-Csv cmdlet. Here's how:

AD
Get-MailboxStatistics | Select-Object DisplayName, TotalItemSize, ItemCount | Export-Csv -Path "C:\MailboxSizes.csv" -NoTypeInformation

Disconnect the Remote PowerShell Session

After you're done, don't forget to disconnect the remote PowerShell session:

📎 Attach files to emails in Windows 11 Mail with the paperclip icon in the compose toolbar. You can attach documents, photos, and more. Tip: for large files, use OneDrive link sharing instead! ☁️ #ConnectedGeek #Windows11 #Mail #Email
📎 Attach files to emails in Windows 11 Mail with the paperclip icon in the compose toolbar. You can attach documents, photos, and more. Tip: for large files, use OneDrive link sharing instead! ☁️ #ConnectedGeek #Windows11 #Mail #Email
How to Extract Email Addresses from MBOX file?
How to Extract Email Addresses from MBOX file?
Uninstall Pre-Installed Microsoft Store Apps using PowerShell
Uninstall Pre-Installed Microsoft Store Apps using PowerShell
I didn’t realize this hidden folder was taking up 60GB of space
I didn’t realize this hidden folder was taking up 60GB of space
vMail PST Email Address Extractor
vMail PST Email Address Extractor
Outlook blocks Safe Senders list in Windows 11 [Fix]
Outlook blocks Safe Senders list in Windows 11 [Fix]
Remove-PSSession $Session

Troubleshooting Common Issues

If you encounter any issues, make sure you've entered the correct credentials and that your Office 365 account has the necessary permissions. Also, ensure that you've installed the latest version of PowerShell and the Remote PowerShell module for Exchange Online.

Conclusion

Retrieving mailbox sizes in Office 365 using PowerShell is a powerful and efficient way to manage and monitor your organization's mailboxes. By following this guide, you can easily identify large mailboxes, export the data for further analysis, and take necessary actions to keep your mailboxes healthy and well-managed.

AD
How can I | create a new version | my DSPCB project
How can I | create a new version | my DSPCB project
Extract email addresses and other data from files on Windows - gHacks Tech News
Extract email addresses and other data from files on Windows - gHacks Tech News
How to display First Page of Office document as its Icon
How to display First Page of Office document as its Icon
How to Save Commonly Used Searches in Outlook
How to Save Commonly Used Searches in Outlook
Manage User Accounts in Windows Home Server
Manage User Accounts in Windows Home Server
ZSoft Uninstaller, Monitor Installations, Uninstall Software - gHacks Tech News
ZSoft Uninstaller, Monitor Installations, Uninstall Software - gHacks Tech News
Special characters not displaying correctly in Outlook
Special characters not displaying correctly in Outlook
Unable to send Email to Groups in Outlook
Unable to send Email to Groups in Outlook
How to Back Up All Your Outlook Data
How to Back Up All Your Outlook Data
Microsoft Dynamics 365 app for Outlook installation failed
Microsoft Dynamics 365 app for Outlook installation failed
How To Download & Install The Quilt Loader | 9Minecraft.Net
How To Download & Install The Quilt Loader | 9Minecraft.Net
A look at Desktop Environments: Openbox Window Manager - gHacks Tech News
A look at Desktop Environments: Openbox Window Manager - gHacks Tech News
OlFix Repair tool for Microsoft Outlook - gHacks Tech News
OlFix Repair tool for Microsoft Outlook - gHacks Tech News
Other User Account names not displaying on Login Screen in Windows 11/10
Other User Account names not displaying on Login Screen in Windows 11/10
AD