Finding High Item Count Folders Using the Exchange Management Shell
Published Dec 07 2009 04:06 PM 60.9K Views


EDIT 06/18/2010: Few post changes to match the newest version of the script.

Working in Exchange Customer Service and Support, we often see cases where user performance, or overall server performance, is impacted because of a high number of items in critical folders within user's mailboxes. This issue has already been documented in multiple places, including the following articles:

Understanding the Performance Impact of High Item Counts and Restricted Views

Using PFDAVAdmin to get the item count within the folders on an exchange server

For the past few months, I have been using a simple Exchange Management Shell command to find all folders that have more than a certain number of items. The shell command is as follows:

Get-Mailbox | Get-MailboxFolderStatistics | Where {$_.ItemsInFolder -gt 5000} | Sort-Object -Property ItemsInFolder -Descending | fl Identity, ItemsInFolder

The above command finds all folders in the Organization that have more than 5,000 items, sorts them in descending order, and then gives the full Folder Path and Item Count. By modifying the Get-Mailbox portion of the command, you can target the command to obtain mailboxes from specific Servers or Databases.

Since there are different folder item limits for each version of Exchange, I thought it might be beneficial to write a script that could analyze folders on all versions, and determine if they were over their limit. The limits are as follows:


Folder Item Limit

Exchange 2000/2003


Exchange 2007


Exchange 2010


It should be noted that these numbers are just the Microsoft recommended limits. Actual numbers could vary greatly depending on how many users are over the limit, the way mailboxes are being accessed (i.e. Outlook Cached Mode, Outlook Online Mode, via Mobile Phone, etc.) as well as certain 3rd party application integration.

The script is called HighItemFolders.ps1. It can be used against the entire organization, a single server, or a single database. It has the option to search all folders, or only critical folders. It can find folders above the Microsoft recommended limits, or above a specified value. And it can send the results solely to the screen, or export the results to a CSV file.


The script has the following parameters, which are all optional:


-CriticalFoldersOnly: Specifies whether to check only Critical Folders, which are Calendar, Contacts, Inbox, and Sent Items, or to check all folders. Should be specified as either $true or $false. If omitted, the default value is $true.

-Database: Specifies the target database to retrieve mailboxes from. This switch overrides the -Server switch if both are used.

-DomainController: Specifies the Domain Controller to use for all mailbox and folder tests. If omitted, the default value is $null.

-FormatList: Writes output to the screen in list format instead of table format. Should be input as either $true or $false. If omitted, the default value is $false.

-ItemCount: Ignores the Microsoft recommended item limits, and finds folders with the specified item count.

-OutputFile: Specifies the file to output the results to. This should be a .CSV file.

-ResultSize: Specifies the maximum number of mailboxes to check. If omitted, the default value is unlimited.

-Server: Specifies the target Exchange server to retrieve mailboxes from.



Obtains all users in the organization, and checks only critical folders over the Microsoft recommended item counts:

C:\> .\HighItemFolders.ps1

Obtains all users on a specified database, checks all folders, and outputs to a CSV file:

C:\> .\HighItemFolders.ps1 -Database "e2k7-1\First Storage Group\Mailbox Database" -CriticalFoldersOnly $false -OutputFile output.csv

Obtains all users on a specific Exchange server with more than 1000 items in any folder:

C:\> .\HighItemFolders.ps1 -Server "e2k3-5" -ItemCount 1000


The script always writes output to the screen. If the -OutputFile switch is used, it will write to a file in addition to the screen.

Screen Output:

CSV Output:


The script can be downloaded as an attachment to this blog post, and then executed from the Exchange Management Shell.


1. In some cases, the CSV file does not separate the columns properly when opening it directly with Excel. To format the columns correctly, do the following (with Excel 2007):

  • Open Excel
  • Choose Open, and browse to the CSV file
  • Choose Delimited as the format. Hit Next
  • Use Tab as the Delimiter. Hit Finish.

2. Error detection has been included in the script to determine if any of the mailboxes reside on a database or server that is inaccessible. If so, that database or server will be skipped so we don't have a lengthy timeout for each mailbox. However, this detection only works on Exchange 2007 and higher. Exchange 2003 mailboxes still time out individually if they are inaccessible, and can cause the script to take a very long time to run.

Hope you find this useful!

- Mike Hendrickson 

Version history
Last update:
‎Apr 29 2020 11:49 AM
Updated by: