How to get an accurate message count for a user mailbox?

Iron Contributor

We have a process by which we decommission a user mailbox after they have left the firm and that involves having a 3rd party archiving solution archive all of their messages then remove them from the users mailbox.

Prior to removing the users mailbox we want to verify that the message count for that mailbox is zero.  Unfortunately, both Get-MailboxStatistics and Get-MailboxFolderStatistics both appear to count hidden messages in the mailbox.   For example, we've confirmed that there are no visible items in any folder of a particular user by viewing all of these folders in Outlook.   However, Get-MailboxFolderStatistics returns 7 items and Get-MailboxStatistics returns an ItemCount of 3 and and AssociatedItem count of 8 so all of this is is obviously not accurate in terms of actual messages.

I understand that Get-MailboxFolderStatistics does enumerate hidden items but I'm surprised that Get-MailboxStatistics has the same issue and there is no apparent way to get an accurate count of messages in a users mailbox.  

Does anyone have insight on how to get an accurate message count for a user mailbox ?

4 Replies
You have the VisibleItemsInFolder property in Get-MailboxFolderStatistics output, which should give you a count that matches what you see in clients.
Hello Vasil,

Thanks for your response. I'm not seeing where VisibleItemsInFolder is a valid property for Get-MailboxFolderStatistics . I've looked at that on Exchange 2019/2016/2013.
Hm, I tested only against Exchange Online, so it might be a cloud-only thing :\

[18:23:41][O365]# Get-MailboxFolderStatistics vasil -FolderScope Inbox | select *ItemsInFolder*

VisibleItemsInFolder : 6615
HiddenItemsInFolder : 150
ItemsInFolder : 6765
DeletedItemsInFolder : 0
ItemsInFolderAndSubfolders : 6777
DeletedItemsInFolderAndSubfolders : 0
Thanks for checking Vasil.