Get Recoverable Items Statistics for Exchange Online using PowerShell
Question details
An administrator needs to retrieve folder statistics for the Recoverable Items folder across all cloud-only Exchange Online mailboxes.

- Product
- Exchange Online
- Device & OS
- not provided
- Scenario
- Managing Microsoft 365 mailboxes and generating storage reports for Recoverable Items folders using automation.
- Observed behavior
- The administrator has an on-premises PowerShell script and wants to know if it will work unchanged for cloud-only mailboxes to extract item counts and sizes.
Ensure you have the Exchange Online PowerShell module (V2 or V3) installed and possess Exchange Administrator or Global Administrator privileges in your Microsoft 365 tenant.
Use Exchange Online PowerShell to Retrieve Statistics
Connect to Exchange Online and utilize the Get-EXOMailboxFolderStatistics cmdlet to safely extract data for cloud-only mailboxes.
On-premises Exchange Server scripts generally cannot be used unchanged in a cloud environment. Attempting to use a standard remote PowerShell session to an on-premises server will fail to find cloud-only mailboxes. Instead, you must authenticate directly to Exchange Online and use the optimized Exchange Online cmdlets.
Open PowerShell as an administrator and run 'Connect-ExchangeOnline' to authenticate with your administrator credentials.
Use the command '$Mailboxes = Get-EXOMailbox -ResultSize Unlimited' to gather all mailboxes in your tenant.
Loop through the collected mailboxes and run 'Get-EXOMailboxFolderStatistics -Identity $mailbox.UserPrincipalName -FolderScope RecoverableItems' to fetch specific metrics.
Pipe your collected data, including mailbox identity, item count, and folder size, into the 'Export-Csv' cmdlet to generate a spreadsheet-ready report file.

Analyze Your Exported CSV Reports with WPS Office
While PowerShell helps you retrieve Exchange data, analyzing those exported CSV files requires a robust spreadsheet tool. WPS Office provides a free, lightweight, and highly compatible alternative to Microsoft Office for reviewing administrative logs and generating reports.
- 1. Download WPS Office: Install WPS Office for free on your operating system.
- 2. Open CSV Reports: Launch WPS Spreadsheets and open the CSV file generated by your Exchange Online PowerShell script.
- 3. Format and Analyze: Use built-in filters, pivot tables, and formatting tools to easily digest your Recoverable Items statistics.

Frequently Asked Questions
Why does my on-premises Exchange PowerShell script fail in Exchange Online?
Exchange Online utilizes different connection endpoints and relies on optimized modules (like the EXO V3 module). On-premises scripts often use older cmdlets or attempt to connect to a local server, which cannot natively query cloud-only mailboxes.
Can I retrieve statistics for only specific mailboxes instead of all of them?
Yes. Instead of using '-ResultSize Unlimited', you can filter mailboxes using the '-Filter' parameter with Get-EXOMailbox, or pipe a specific list of user identities from a text file into your script loop.
What permissions do I need to run Get-EXOMailboxFolderStatistics?
You must be assigned appropriate administrator roles in Exchange Online, such as Organization Management, View-Only Organization Management, or Recipient Management, to retrieve folder statistics across the tenant.




