Link to home
Start Free TrialLog in
Avatar of Neil Randall
Neil RandallFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Incorrect totals from exchange Get-MailboxFolderStatistics cmdlet

I am trying to use PowerShell to provide me with the total number of items that a user has in their Inbox. This will help in managing users who are not organising their email system properly. (in the past we have had users with 4000+ emails in their Inbox!
I run this in the Exchange 2010 Management Shell:

Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.Name -match "Inbox"} | Select Identity, Name, ItemsInFolder | Sort-Object ItemsInFolder -descending | Export-csv c:\temp\MailboxItemCountInbox.csv


It looked like it provided what I needed until I looked at the totals. Mine for instance.
The spreadsheet from the above command shows that I have 190 items in my Inbox. I actually have 156!
I understand (from other forums) that this command will also take into account unopened emails.
I have unopened:
66 Deleted
21 drafts
4 Saved Folder
145 Junk Mail
No matter which way I look at these figures i cannot get them to add up to the 190 items reported.
I find this with all the other users.

Am I missing something in the command that will give me an accurate snapshot of the number of items in a users Inbox?

Thanks for your time in viewing this post
Avatar of Muhammad Mulla
Muhammad Mulla
Flag of United Kingdom of Great Britain and Northern Ireland image

Are you just looking for items in the inbox folder or in all folders in the mailbox.

Bear in mind that mailbox folders includes calendar and contacts folders.
Avatar of Will Szymkowski
Are you using cached mode on your mailbox? Depending on the state of your OST it could be off slightly compared to your mailbox on the server. Also depending how much you are caching to this OST file as well.

Try Outlook in online mode and see if the count is the same. If it is and is only different when using cached mode this is excepted.

Will.
Avatar of Neil Randall

ASKER

OfflineGeek
For now I am only looking for the total number of mail items in each users mailbox. Once I can get this sorted, I would want to run the procedure against Sent Items and Deleted Items.

Will Szymkowski
I am using cached mode and have always known there is some lag between the client and the server. However if anything the count in my Outlook client should show more items, just going of the data file properties - folder size - of the Inbox Folder. The server shows less than the client!
It is not just 1 or 2 items out, it is 30 - 40 items out in the count 190+ in the report from Exchange but 150+ items in my Inbox.
I have run this a couple of times this afternoon with very little changing (in fact my mailbox has been very quiet over the last 24 hours, for once!).
It just looks like there is something else the command is including in the output rather than just the number of items in each Inbox.
ASKER CERTIFIED SOLUTION
Avatar of Will Szymkowski
Will Szymkowski
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks Will

I tried this on the server using the Exchange Shell, but this command will only give me 'Total' stats for all mail items in a user's mailbox. I am trying to get a snapshot count of how many mail items (opened & unopened) there are in every users Inbox only.

Neil
I do not believe you can do this with native powershell cmdlets. I would try the suggestion at the following link.
Outlook UnRead Item Count

Will.
Thanks Will

You pointed me in the right direction, but this finally got me closer to what I want.

It still does not give me an exact or 'live' total, but is usually within 20 - 30 items. As I am only interested in those users who have hundreds of emails in their Inbox, or are nesting folders in their Inboxes, this solution just about does the job.

Get-Mailbox | Get-MailboxFolderStatistics -FolderScope All | Sort-Object FolderSize -Descending | Where-Object {$_.FolderPath -like "/Inbox*"} | select-object Identity,FolderSize,ItemsInFolder |  Export-Csv c:\temp\MailBoxItemCount.csv