Finding large items in Exchange mailboxes

Problem:

You want to find and list the largest items in Exchange mailboxes.

Solution:

This article helps you list the largest items in mailboxes. This knowledge can be useful in various circumstances.

For example, you want to migrate an Exchange organization, and the target Exchange Server's message size policies are more strict than in your current environment. In the case of on-premises Exchange Server environments, these limits can be modified (see our Knowledge Base article), but such an operation might not be available for you due to specific policies in your organization. Also, in the case of Exchange Online (Office 365), there is a fixed (unchangeable) 150 MB limit per message set by Microsoft. In such a case, you might need to locate all large-sized messages in the source mailboxes to remove or achive them, etc.

To make things complicated, it is not possible to list items larger or equal to a specific value in users' mailboxes without using dedicated third-party tools or creating complicated PowerShell scripts that connect to your Exchange via EWS.

Fortunately, in MS Exchange Server 2010 and newer, you can search mailboxes for the single largest item in every mailbox folder. Additionally, you can filter the output to items bigger than a specific size. Follow the steps below.

  1. Start the ems Exchange Management Shell.
  2. Review the PowerShell cmdlet below, customize it to suit your needs, then execute it. Be aware that running this cmdlet may take even a few minutes and can affect your server's performance (depending on the number of mailboxes and their contents).
    Get-Mailbox -ResultSize Unlimited | Get-MailboxFolderStatistics -IncludeAnalysis -FolderScope All | Where-Object {(($_.TopSubjectSize -Match "MB") -and ($_.TopSubjectSize -GE 50.0)) -or ($_.TopSubjectSize -Match "GB")} | Select-Object Identity, TopSubject, TopSubjectSize | Export-CSV -path "C:\report.csv" -notype
    

    You can customize the above commandlet in many ways, for example by changing the value 50.0 used in the example above, you can apply a different message size filter. Substituting Get-Mailbox -ResultSize Unlimited with Get-Mailbox -Identity Administrator limits the search only to the administrator's mailbox, etc.

  3. As a result, a report.csv file is created in the location you specified (C:\ in the example above). The report file contains a list of mailbox folders with subjects and sizes of the largest items in those folders. If the cmdlet was defined as shown above, the search results will be limited to items larger than 50 MB.

Keep in mind that on certain workstations, the path C:\ may not be writable, so you need to change it.