Get-MailboxFolderStatistics ItemsInFolder also returns subfolder counts and counts are not correct

Question:

I’m using PowerShell to return a report of Exchange mailbox statistics as a tab-delimited text file. I’m having trouble with the ItemsInFolder property of the Get-MailboxFolderStatistics cmdlet (from the Microsoft.Exchange.Management.PowerShell.e2010 snapin). If I run it against a mailbox like this:

it yields the following:

but the count in the inbox folder as viewed through Outlook is 513. I found this TechNet article that has a note that says

A mailbox can have hidden items that are never visible to the user and are only used by applications. The Get-MailboxFolderStatistics cmdlet can return hidden items for the following values: FolderSize, FolderAndSubfolderSize, ItemsInFolder, and ItemsInFolderAndSubfolders.

but I fairly certain this folder doesn’t have any hidden items. Also, if I add a folder beneath the Inbox and move some items into it then run the cmdlet again, it reports the counts for BOTH folders:

it’s my understanding that the ItemsInFolderAndSubfolders property was supposed to return counts for sub-folders, not the ItemsInFolder property. So here are my questions:

  1. how do I get the cmdlet to return values for only the root folder provided, and
  2. how do I get it to return only items that are visible to the user?

Answer:

Instead of your current command, run this command, and look for the appropriate property/value pair in the command’s output.

That will retrieve all of the properties on the object, and allow you to find the appropriate one.

Source:

Get-MailboxFolderStatistics ItemsInFolder also returns subfolder counts and counts are not correct by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply