How To Export Users Mailbox Size from Exchange Online into CSV File?

Often, admins need to know the mailbox size for analysing the Exchange Server or reporting. Also, sometimes the need mailboxes size to understand when the face performance issue.

Let’s see how can you solve this problem. Below I have discussed two methods, and let’s see how you can know mailbox size and save it into a CSV file.

Solution 1

In this method, you can directly export mailbox size from Exchange Online into CSV file Office 365 admin panel.

For this, you can first go to Office 365 Central Admin -> Usage -> Mailbox Usage.

Here you find three options Mailbox, Storage and Quota.

By default, its selected Mailbox Tab.

On the right side, you can find the Export option.

After clicking on Export, you can easily download the Mailbox size in CSV File.

Note: You can also change the details by using different times here.

Solution 2

In this method, you can use the below script to export data to a CSV file. By default, it saves the mailboxstas.csv name.

$Maiboxes = Get-Mailbox | ? {$_.RecipientTypeDetails -eq "UserMailbox"}
$Result1 = @()
foreach ($Maibox in $Maiboxes) {
$a = Get-MailboxStatistics $Maibox.Alias | select TotalItemSize,Displayname
$b = Get-MailboxFolderStatistics $Maibox.Alias | ? {$_.Name -eq "Recoverable Items"} | select @{Expression={};Label="Name";}, @{Expression={};Label="MailboxSize";}, @{Expression={$_.FolderAndSubfolderSize};Label="RecoverableItemsSize";}
$b.Mailboxsize= $a.TotalItemSize
$b.Name =  $a.Displayname
$Result1 += $b

}
$Result1 | Export-Csv C:\Users\Administrator\Desktop\mailboxstas.csv -NoTypeInformation

How Can you see recoverable items size?

The recoverable item’s size is not shown in Usage Report. For this, you need to use the above scripts.

Here are the steps to save recoverable items size

– Copy the above scripts

– And save as PS1 File

– Now open Windows PowerShell

– Now Connect to Exchange Online PowerShell

– Now, Run the scripts

– Now, you can see recoverable items here.

Note – By default its show only 100 users list.   To show maximum items. For this, you can set -ResultSize to “unlimited” in the first line.

$Maiboxes = Get-Mailbox -ResultSize unlimited| ? {$_.RecipientTypeDetails -eq "UserMailbox"}
$Result1 = @()
foreach ($Maibox in $Maiboxes) {
$a = Get-MailboxStatistics $Maibox.Alias | select TotalItemSize,Displayname
$b = Get-MailboxFolderStatistics $Maibox.Alias | ? {$_.Name -eq "Recoverable Items"} | select @{Expression={};Label="Name";}, @{Expression={};Label="MailboxSize";}, @{Expression={$_.FolderAndSubfolderSize};Label="RecoverableItemsSize";}
$b.Mailboxsize= $a.TotalItemSize
$b.Name =  $a.Displayname
$Result1 += $b

}
$Result1 | Export-Csv C:\Users\Administrator\Desktop\mailboxstas.csv -NoTypeInformation

Summery

I hope this short blog can help export users’ mailbox size from Exchange Online into CSV File. You can contact me anytime If there is any query.

Amit Singh

Amit Singh

I am a dynamic Tech Enthusiast, specializing in various Microsoft technologies, including Office 365, Exchange, PowerShell, and Active Directory. I loved to helped customers worldwide design, implement, migrate, and secure Exchange and Office 365 through various roles for different employers, and more recently, as an independent consultant.