Why do content reports return fewer items than PowerShell?
Promodag Reports contains several reports to show the size of a mailbox and the number of its items in the Storage and Mailbox Content categories. However, you will notice discrepancies in the results. Here is the explanation.
Mailbox size: a relative concept
First of all, it is probably not an exaggeration to say that the notion of mailbox size is quite subjective since the mailbox structure consists of all kinds of elements and folders visible and invisible to the end user.
- This article by Vasil Michev shows the complexity of the thing: Using PowerShell to explore the Non-IPM subtree of an Office 365 mailbox.
- Tony Redmond has also published an excellent article on this subject: What’s the Real Size of Exchange Online Mailboxes?
Both are recommended readings.
From the PowerShell side
PowerShell provides two main commands to perform this search:
- The PowerShell cmdlet Get-EXOMailboxStatistics defaults to retrieving the size of the IPM subtree, but it is not clear which folders it considers.
- The PowerShell cmdlet Get-EXOMailboxFolderStatistics retrieves the list of folders, with their size and number of items.
If you run these two commands on a mailbox, you will get different results.
- Get-EXOMailboxStatistics returns inferior results to Get-MailboxFolderStatistics, that lists invisible folders in Outlook: PersonMetadata, Recipient Cache, Audits, Purges etc.
- Furthermore, Get-MailboxFolderStatistics also returns results that do not match what you can see in Outlook. The underlying reason for this discrepancy is not clear.
From the Promodag Reports side
Now here's what Promodag Reports does if you look under the hood:
- The Mailbox Storage Information and Mailbox Size Fluctuation reports (Storage category) uses the data returned by Get-EXOMailboxStatistics.
- The Mailbox Content Summary and Item Breakdown by Age reports (Mailbox Content category) scans all items in the visible folders to sort them by age, the count and size is that of the scanned items. Items without a delivery date are ignored (for example: all Contacts).
- The General Mailbox Content, Mailbox Folder Size and Item Breakdown by Size reports (also Mailbox Content category) use the TotalCount and PR_MESSAGE_SIZE folder properties in Outlook, also for visible folders.
So to summarize, Promodag Reports exploits the properties of the folders visible by the user in Outlook and returns the size and number of items as Outlook presents them. In the case of Mailbox Content Summary, or Item Breakdown by Age, some items are ignored due to the lack of delivery date in the mailbox.
To verify these statements, perform the following test on a random (and preferably used) mailbox:
- Run this command and write down how many items you get: Get-EXOMailboxStatistics -Identity <email address of the mailbox>
- Run this one, retrieve the output file in C:\Temp and sum up the item count in Excel: Get-EXOMailboxFolderStatistics -<email address of the mailbox>| Select Name,FolderSize,ItemsinFolder | export-csv "C:\Temp\MailboxFolderStatistics.csv" -delimiter ';' -Encoding UTF8
- Run the Mailbox Content Summary report on the mailbox;
- Run the Mailbox Folder Size report on the mailbox.
You can expect to get four different results although quite close. The report that should return the closest result to what you see in the Outlook client is Mailbox Folder Size, but it is clear from reading the articles linked above that this is all relative.
We will endorse the conclusion of Tony Redmond in his above-mentioned article:
"It’s difficult to figure out the exact size for an Exchange Online mailbox on disk. Suffice to say that it’s larger than you think, but as Microsoft doesn’t document how it stores application data inside mailboxes, all we can do is test, observe, and speculate".