Updated 4 days ago

Export Exchange Online Mailbox Folder Statistics Using PowerShell

by Sruthy

5 min read

No Comments

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

  1. The script verifies and installs Exchange PowerShell module (if not installed already) upon your confirmation.
  2. Retrieve folder statistics for all mailbox folders.
  3. Retrieve statistics for specific mailbox folders.
  4. Provides folder statistics for a single user and bulk users.
  5. Allows to use filter to get folder statistics for all user mailboxes.
  6. Allows to use filter to get folder statistics for all shared mailboxes.
  7. The script can be executed with an MFA-enabled account too.
  8. Exports report results to CSV.
  9. The script is scheduler friendly.
  10. It can be executed with certificate-based authentication (CBA) too.

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

MailboxFolderStatisticsReports - Output

Exchange Online Mailbox Folder Statistics Report – Script Execution Methods

  1. Download the script.
  2. Start the Windows PowerShell.
  3. Select any of the methods provided to execute the script.

Method 1: You can run the script with MFA and non-MFA accounts.

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.

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.

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:

  1. Get Mailbox folder size for all Exchange mailboxes
  2. Get mailbox folder statistics for a single user
  3. Obtain mailbox folder statistics for bulk users
  4. Find mailbox folder size for all user mailboxes
  5. Get mailbox folder statistics for all Microsoft 365 shared mailboxes
  6. 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.

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.

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.

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:
Mailbox folder statistics - Bulk user upload input

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.

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.

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.

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!

Share article