As an admin, monitoring Exchange Online mailbox folder insights is essential to find out the item count and the folder size of all mailboxes, optimizing storage management. As the Microsoft 365 admin center doesn’t provide information about mailbox folder size details, admins need to go with any third-party tool or PowerShell. Let’s dive into how to get mailbox folder statistics using Exchange PowerShell.
Find Mailbox Folder Insights Using PowerShell
Admins can find mailbox folder statistics report using Get-MailboxFolderStatistics cmdlet in the Exchange Online PowerShell module. This cmdlet retrieves mailbox folder size and item count for all mailbox folders including archive, inbox, calendars, contacts, and more. However, admins need to spend more time to tweak and get the desired details using this cmdlet. Drop your worries! We have crafted a PowerShell script which offers tailored solutions for all your use cases effectively.
Script Highlights
- The script verifies and installs Exchange PowerShell module (if not installed already) upon your confirmation.
- Retrieve folder statistics for all mailbox folders.
- Retrieve statistics for specific mailbox folders.
- Provides folder statistics for a single user and bulk users.
- Allows to use filter to get folder statistics for all user mailboxes.
- Allows to use filter to get folder statistics for all shared mailboxes.
- The script can be executed with an MFA-enabled account too.
- Exports report results to CSV.
- The script is scheduler friendly.
- It can be executed with certificate-based authentication (CBA) too.
Download Script: GetMailboxFolderStatisticsReport.ps1
Sample Output:
The script exports all the Microsoft 365 mailboxes available in the organization with the following attributes:
- Display Name
- UPN
- Folder Name
- Folder Path
- Items in Folder
- Folder Size
- Items in Folder and Subfolders
- Folder and Subfolder Size
- Deleted Items in Folder
- Deleted Items in Folder and Subfolders
- Visible Items in Folder
- Hidden Items in Folder
- Mailbox Type
- Creation Time
- Last Modified Time
Exchange Online Mailbox Folder Statistics Report – Script Execution Methods
- Download the script.
- Start the Windows PowerShell.
- Select any of the methods provided to execute the script.
Method 1: You can run the script with MFA and non-MFA accounts.
1 |
./GetMailboxFolderStatisticsReport.ps1 |
This example enables you to export all the Exchange Online mailboxes and their folder statistics for each folder into a CSV file.
Method 2: You can also run the script using certificate-based authentication, which is scheduler friendly. When you want to run the script unattended, you can choose this method. To do this, you must register the app in Azure AD.
1 |
./GetMailboxFolderStatisticsReport.ps1 -Organization <Domain> -ClientId <AppId> -CertificateThumbprint <CertThumbprint> |
You can use either a certificate issued by a recognized certificate authority (CA) or create a self-signed SSL certificate.
Method 3: You can explicitly pass credentials (username and password) and execute the script.
1 |
./GetMailboxFolderStatisticsReport.ps1 -UserName <UPN> -Password <Password> |
You can schedule the script using task scheduler for non-MFA admin accounts.
Export Mailbox Folder Statistics Using PowerShell Script
By using the script, you can get solutions for the following use cases:
- Get Mailbox folder size for all Exchange mailboxes
- Get mailbox folder statistics for a single user
- Obtain mailbox folder statistics for bulk users
- Find mailbox folder size for all user mailboxes
- Get mailbox folder statistics for all Microsoft 365 shared mailboxes
- Export specific folder size for all mailboxes
1. Get Mailbox Folder Size for all Exchange Mailboxes
Monitoring mailbox folder insights for all Exchange Online mailboxes helps to get an overview of all folders and their sizes. Thus, admins can easily monitor mailbox usage and optimize mailbox storage efficiently.
To get and export mailbox folder statistics for all Exchange Online mailboxes to a CSV file, run the script as below.
1 |
./GetMailboxFolderStatisticsReport.ps1 |
Admins will get folder’s items count and folder size for each mailbox separately.
Moreover, admins can also monitor mailbox folder permission report to prevent excessive privileges on confidential folders, enhancing overall mailbox security.
2. Get Mailbox Folder Statistics for a Single User
If admins want to monitor folder insights for a crucial mailbox, run this script by specifying the desired user’s UPN in the ‘-MailboxUPN’ parameter.
1 |
./GetMailboxFolderStatisticsReport.ps1 -MailboxUPN <UserPrincipalName> |
The exported report shows each folder’s size of the specified user, focusing crucial mailbox and avoiding others.
3. Obtain Mailbox Folder Statistics for Bulk Users
Retrieving mailbox folder statistics for multiple mailboxes helps admins to monitor folder details for a specific set of users in the organization.To achieve this, run the script with ‘-MailboxCSV’ param to provide the file path.
1 |
./GetMailboxFolderStatisticsReport.ps1 -MailboxCSV <FilePath> |
Replace <FilePath> with the path of your saved CSV file.
Note: Remember that you must add the desired users’ UPN with the column name ‘Mailboxes’ in the CSV file.
Sample Input CSV File:
4. Find Mailbox Folder Size for all User Mailboxes
Admins can get mailbox folder insights for user mailboxes alone to focus only on users and eliminating other mailbox types for enhanced monitoring. Run the script with ‘-UserMailboxOnly’ parameter to get folder details of all user mailboxes.
1 |
./GetMailboxFolderStatisticsReport.ps1 -UserMailboxOnly |
It exports each folder items count and size for all the user mailboxes separately.
5. Get Mailbox Folder Statistics for all Microsoft 365 Shared Mailboxes
Shared mailboxes consume more storage than user mailboxes. So, it is essential for admins to keep track of the crucial shared mailbox folder statistics periodically and identify shared mailbox size effectively.
1 |
./GetMailboxFolderStatisticsReport.ps1 -SharedMailboxOnly |
Admins can run the script with ‘-SharedMailboxOnly’ param as mentioned above to retrieve each folder details for all shared mailboxes in Microsoft 365 environments.
6. Export Specific Folder Size for all Mailboxes
All the folders in a mailbox may not be required for monitoring. Admins can focus on crucial mailbox folders or can get folder statistics for default folders by specifying the required folder paths separated by a comma using the ‘-FolderPaths’ parameter while running the script.
1 |
./GetMailboxFolderStatisticsReport.ps1 -FolderPaths “/Inbox” |
Running the above script exports the inbox folder details like item count, size, hidden items, visible items, deleted items, subfolder details for all Exchange Online mailboxes.
Monitoring mailbox folder statistics is essential for admins to optimize storage and manage mailboxes efficiently. Apart from this, reviewing mailbox permissions, mailbox quota, memberships, ownerships, configuration changes are crucial for proper mailbox management. Here comes AdminDroid Exchange Online management tool! It provides end-to-end details of Exchange Online mailboxes with crystal clear stats and appealing graphs to solve all the admin’s requirements and step up your mailbox management like never before.
Hope this blog helps admins to find and export mailbox folder statistics report which solves all the use cases efficiently. Drop your queries in the comment section. Happy scripting!