Goodbye Exchange ExMerge, Hello Export-Mailbox

ExMerge was a great way of exporting a mailbox to an Exchange PST file, or for removing all occurences of an email virus, but it has now been replaced by two new Exchange Management Shell cmdlets, Export-Mailbox and Import-Mailbox which are equally as useful to have at hand.

Most Exchange administrators who’ve worked with Exchange prior to Exchange 2007 will be familiar with ExMerge.  It was a useful tool to have available if you needed to export a mailbox to a PST file, for example if a user left and wanted to take a copy of their mailbox with them, or you needed a PST file as an archive copy of one or more mailboxes.  It was also useful if you needed to search your Exchange databases for a particular message and remove it, such as removing an email virus.

ExMerge was born in the Exchange 5.5 days as a product support tool, and was later re-released for Exchange 2003 as a web download.  In Exchange 2007 ExMerge has been replaced by two new Exchange Management Shell cmdlets, Export-Mailbox and Import-Mailbox.  The RTM release of Export-Mailbox was limited to moving messages only from one mailbox to another, but the SP1 release was enhanced to include the export-to-PST functionality which is familiar to ExMerge users, and that’s the version I’m referring to in this article.  There is no graphical interface for either Export-Mailbox or Import-Mailbox; they are only available in the shell.

It’s important to note that Export-Mailbox is not intended for use as an Exchange migration tool.  It’s designed for moving mailbox content rather than an entire mailbox.  If you need to migrate an entire mailbox you should use the Move-Mailbox cmdlet.

At a high level, Export-Mailbox can be used to

  • Export mailbox content from a mailbox to another mailbox
  • Export mailbox content from a mailbox to a PST file

During mailbox exports content can be filtered by:

  • Included or excluded folders
  • Message sender keywords
  • Message recipient keywords
  • Message subject keywords
  • Message and attachment content keywords
  • Attachment file names
  • Date range

If you’re going to use the filter options, make sure you have at least Update Rollup 4 for Exchange 2007 SP1, as this update included improvements to the filtering options.

When keyword filter options are specified Export-Mailbox will first export all the messages in each from the source mailbox to the destination mailbox. The folder in the destination mailbox is then searched and messages which do not match the keyword filters are deleted.  On large mailboxes this can be a time consuming and resource intensive operation.

Other options are available to:

  • Merge content from the source to the destination (the top level folder is not time stamped)
  • Delete content from the source mailbox after it has been exported
  • Include associated messages such as rules, views, and forms
  • Increase the number of threads
  • Write output to an XML log file


The source and destination mailbox must be located on one of these versions of Exchange:

  • Exchange 2007
  • Exchange Server 2003 SP2 or later
  • Exchange 2000 SP3 or later


Export-Mailbox will export any items in mailbox’s dumpster by converting  them back to regular messages. 

For multiple mailbox exports, the output of the Get-Recipient or Get-Mailbox cmdlets can be piped to Export-Mailbox.  When piping input to Export-Mailbox, the MaxThreads parameter can be used to increase the number of mailboxes processed simultaneously.

Copying mailbox content to a subfolder in another mailbox

This might be the case if you have a user who has left and you need to move some or all of their mailbox content into the mailbox of another user such as their co-worker, manager, or replacement, before the leaving user’s mailbox is deleted.

This is the command to export the content from Joe’s mailbox to a folder name “Joe” in Bob’s mailbox:

The exported content will look like this:


Optionally the AllowMerge parameter can be used to merge the content into the target folder. When using the AllowMerge parameter the top-level folder isn’t time-stamped, this means that the source mailbox content can be exported to the destination multiple times:


Specific folders can be included or excluded by using the IncludeFolders and ExcludeFolders parameters. For example, to include only the Inbox and Contacts folders:

To export all content except for the Sent Items and Deleted Items folders:

Exporting mailbox content to a PST file

If a user is leaving and wants to take a copy of their mailbox you can use Export-Mailbox to move the data directly into a PST file.

Tip: To export mailbox content to a PST file you must run Export-Mailbox on a 32-bit Windows computer running the 32-bit version of the Exchange 2007 management tools, and Microsoft Outlook 2003 SP2 or later.

To export a user named Joe’s mailbox to the PST file C:\Temp\joe.pst:

To export all the mailboxes in the sales mailbox database to individual PST files named <alias.pst>:

Searching for and removing content from a mailbox

If a virus has found its way into your Exchange organisation, or if a message has been delivered to a large number of mailboxes and you need to remove it, you can use Export-Mailbox to search mailboxes and remove the message.

Tip: Because Export-Mailbox first copies all content to the destination mailbox before performing the search the target mailbox can get quite large and will have a lot of IO.  It’s a good idea to use a mailbox created specifically for this task, especially if you are performing the search over many mailboxes and using the MaxThreads parameter to increase the default number of threads.

To remove any message with the words “Company confidential” in the subject line from all mailboxes on the server EXCHANGE01, processing 10 mailboxes at a time:

To remove any messages from the sender from all mailboxes on the server EXCHANGE01, processing 10 mailboxes at a time:

The messages will be copied to the “MessageCleanup” folder in the target mailbox and deleted from the source mailboxes.  The target folder will include a replica of the folder structure in each of the source mailboxes.


Troubleshooting Export-Mailbox

The most common problems with using Export-Mailbox are related to permissions.  To use Export-Mailbox you need to be delegated the Exchange Server Administrator role, be a member of the local Administrators group for the target server, and have full access to the source and destination mailboxes.  The source and destination mailboxes must be in the same Active Directory forest.

These are some common permissions-related errors:

Error Cause

“The specified mailbox database [Mailbox Database Name] does not exist”

 The user running the Export-Mailbox command needs to be delegated the Exchange Administrator role for the Exchange server.

“Error occurred in the step: Creating target folder in the target mailbox. An unknown error has occurred., error code: -2147221233”

The user running the Export-Mailbox does not have full access to the destination mailbox.

 Error occurred in the step: Moving messages. Failed to copy messages to the destination mailbox store

 with error:

MAPI or an unspecified service provider.

ID no: 00000000-0000-00000000, error code: -1056749164″

The user running the Export-Mailbox does not have full access to the source mailbox.

ExMerge may be gone, but Export-Mailbox is equally as useful a tool to have at hand.  The flexible filtering options make it possible to do more granular exports than were possible with ExMerge, and the command shell interface makes it easy to script.

More information on Export-Mailbox can be found on the Microsoft TechNet website:

More information about the dumpster can also be found on the TechNet website: