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

exchange-server, exchange-server-2010, powershell

Solution

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

Get-MailboxFolderStatistics myusername -FolderScope Inbox | Select-Object -Property *;

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

Problem

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: ``` Get-MailboxFolderStatistics myusername -FolderScope Inbox | Select ItemsInFolder ``` it yields the following: ``` ItemsInFolder ------------- 556 ``` 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: ``` ItemsInFolder ------------- 547 11 ``` 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: - how do I get the cmdlet to return values for only the root folder provided, and - how do I get it to return only items that are visible to the user?

Original source