Get Exchange Online Mailbox Size in GB
In this article we will learn how to PowerShell commands to get Exchange Online Mailbox size in GB.
Table of Contents
Get Exchange Online Mailbox Size in GB
In Exchange Online, understanding mailbox size and usage is crucial for efficient resource management and ensuring optimal email performance. The Get-MailboxStatistics cmdlet provides valuable insights into mailbox statistics, including size, last logon time, and quota information. In this comprehensive guide, we’ll explore various aspects of mailbox size and usage using Get-MailboxStatistics, covering key metrics such as size in GB and MB, last logon time, total item size, and mailbox quota.
Connect to Exchange Online PowerShell
To be able to run below PowerShell commands, you need to connect to Exchange Online PowerShell module. Open Windows PowerShell as administrator and run below commands one by one:
Install-Module ExchangeOnlineManagement
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline
Get-MailboxStatistics mailbox size in GB
In this example we will use Get-MailboxStatistics command to get mailbox size of all mailboxes in Exchange Online, and then we will display the output in GB.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, @{name=”TotalItemSize (GB)”; expression={
[math]::Round(($_.TotalItemSize.ToString().Split(“(“)[1].Split(” “)[0].Replace(“,”,””)/1GB),2)
}
}, ItemCount | Sort “TotalItemSize (GB)” -Descending
The above command will display the mailbox size of all users in GB as shown below:
Get-MailboxStatistics mailbox size in MB
In this example we will use Get-MailboxStatistics command to get mailbox size of all mailboxes in Exchange Online, and then we will display the output in MB.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select DisplayName, @{name=”TotalItemSize (MB)”; expression={
[math]::Round(($_.TotalItemSize.ToString().Split(“(“)[1].Split(” “)[0].Replace(“,”,””)/1MB),2)
}
}, ItemCount | Sort “TotalItemSize (MB)” -Descending
The above command will display the mailbox size of all users in MB as shown below:
Get-MailboxStatistics mailbox size all users and export to CSV
In this example we will export mailbox size for all mailboxes in Exchange Online organization. Replace “C:\CSV Files\MailboxSize.csv” with the actual CSV file path and run below PowerShell command:
# Get all user mailboxes and their sizes
$mailboxSizes = Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName,ItemCount,TotalItemSize
# Export mailbox sizes to a CSV file
$mailboxSizes | Export-Csv -Path "C:\CSV Files\MailboxSize.csv" -NoTypeInformation
Get-MailboxStatistics lastlogontime
In this example we will get last logon time for all users.
Get-Mailbox -ResultSize Unlimited | Get-MailboxStatistics | Select-Object DisplayName,LastLogonTime
Conclusion
In this article you learn how to use Get-MailboxStatistics PowerShell command to get mailbox size of mailboxes. You also learnt how to get mailbox size in GB and MB.
You might like our other article on Get mailbox size using PowerShell, How to run message trace using PowerShell and Run Extended Message Trace (EMT) using PowerShell.
If you found this article helpful and informative, please share it within your community and do not forget to share your feedback in the comments below.
Join us on YouTube for the latest videos on the Cloud technology and join our Newsletter for the early access of the articles and updates.
Happy Scripting!!