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:
1 2 |
Get-MailboxFolderStatistics myusername -FolderScope Inbox | Select ItemsInFolder |
it yields the following:
1 2 3 4 |
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:
1 2 3 4 5 |
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?
Answer:
Instead of your current command, run this command, and look for the appropriate property/value pair in the command’s output.
1 2 |
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.