Click here to monitor SSC
  • Av rating:
  • Total votes: 78
  • Total comments: 13
Ben Lye

Goodbye Exchange ExMerge, Hello Export-Mailbox

26 February 2009

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:

Export-Mailbox -Identity joe@example.com -TargetMailbox bob@example.com -TargetFolder Joe

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:

Export-Mailbox -Identity joe@example.com -TargetMailbox bob@example.com -TargetFolder Joe –AllowMerge

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

Export-Mailbox -Identity joe@example.com -TargetMailbox bob@example.com -TargetFolder Joe –IncludeFolders \Inbox, \Contacts

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

Export-Mailbox -Identity joe@example.com -TargetMailbox bob@example.com -TargetFolder Joe –ExcludeFolders "\Sent Items", "\Contacts"

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:

Export-Mailbox -Identity joe@example.com –PSTFolderPath C:\Temp\joe.pst

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

Get-Mailbox –Database "Sales Mailbox DB" | Export-Mailbox –PSTFolderPath C:\PSTFiles

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:

Get-Mailbox -Server EXCHANGE01 | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder MessageCleanup -SubjectKeywords "Company confidential" –DeleteContent –MaxThreads 10

To remove any messages from the sender nasty.person@example.com from all mailboxes on the server EXCHANGE01, processing 10 mailboxes at a time:

>Get-Mailbox -Server EXCHANGE01 | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder MessageCleanup -SenderKeywords nasty.person@example.com –DeleteContent –MaxThreads 10

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:

http://technet.microsoft.com/en-us/library/aa998579.aspx

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

http://technet.microsoft.com/en-us/library/aa997155.aspx

Ben Lye

Author profile:

Ben Lye is a senior systems administrator at a multi-national software company. He has over 10 years experience supporting and administering Windows and Exchange, and has been MCSE and MCP certified since 1999. Ben is passionate about automating and streamlining routine tasks, and enjoys creating and using tools which make day-to-day administration easier.

Search for other articles by Ben Lye

Rate this article:   Avg rating: from a total of 78 votes.


Poor

OK

Good

Great

Must read
Have Your Say
Do you have an opinion on this article? Then add your comment below:
You must be logged in to post to this forum

Click here to log in.


Subject: Unbelievable
Posted by: Anonymous (not signed in)
Posted on: Tuesday, March 03, 2009 at 6:53 AM
Message: Your are doing good job.I thankful to you.

This document for very usefull for us.

Thanks & Regards
Paramesh
Mail id:raju_param@yahoo.com

Subject: Exmerge and Export Mailbox
Posted by: Troyw (view profile)
Posted on: Saturday, October 17, 2009 at 6:47 PM
Message: Excellent article, however, IMHO the exmerge and export-mailbox capabilities to be a bit troublesome and wanting. Instead we use the DigiScope http://www.lucid8.com/product/digiscope.asp product since it has a cool gui and can search, slice and dice, recover and export data from Live Exchange Servers as well as offline EDBs

Subject: For exporting your mailbox to PST
Posted by: BobMaria (view profile)
Posted on: Thursday, August 05, 2010 at 5:24 AM
Message: Good article but there are also some softwares for exporting EDB files to PST files.
You can try - http://www.edbtopst.com

Subject: Some of us have to be cheap
Posted by: jmartin95 (view profile)
Posted on: Friday, October 22, 2010 at 10:10 PM
Message: I think the point of the article is what can you do with the exchange software you just purchased without the additional cost of $500 - $750.

I dont know what could be easier than entering a command into the management shell...pretty easy if you ask me. easier on the wallet too.

Great article. Thank you

Subject: Exporting Exchange Mailboxes to a PST
Posted by: shawninc (view profile)
Posted on: Tuesday, August 02, 2011 at 10:13 AM
Message:
1) Download “ExMerge” on to a Windows 2003 server with Exchange running on it.
2) Copy “exchmem.dll” to the folder with the “ExMerge” contents.
3) Give full perms to administrator or the user you logged in as to the server and mailboxes.
a. In Exchange Manager, right click in server, properties and then security
b. Uncheck inherit
c. Add everyone, and give full control to everyone.
d. Take ownership
This ensures that you have the require “send as” and “receive as”, but the step here are very insecure. While this is insecure, it does effectively allow a mailbox backup or each user for a system that is about to be decommissioned.

<a href="http://www.internetworkconsulting.net">Shawn Z</a>

Subject: missing the good old exmerge
Posted by: SZZ (view profile)
Posted on: Monday, August 22, 2011 at 1:21 PM
Message: I do like the new mailbox migrating tool, only it is not working for me. Below is the error message that I am getting and will appreciate is you can suggest a workaround.
Thanks.
--------------start of error message------------
StatusMessage:
Error occurred in the step: Moving messages.
This mailbox exceeded the maximum number of
corrupted items specified for this move mailbox operation.

ReportFile:
D:\Program Files\Microsoft\Exchange Server\Logging\MigrationLogs\export-MailboxXXXXX.xml
-------------end of error message----------------

Subject: Exporting Exchange Mailboxes to a PST
Posted by: kottees (view profile)
Posted on: Wednesday, September 07, 2011 at 1:19 PM
Message: Great!! it worked like a charm!

Subject: Re: export mailbox to pst
Posted by: luisbob (view profile)
Posted on: Tuesday, November 22, 2011 at 8:49 PM
Message: There’s no doubt about the new tool, It is much better than the old relatively limited and error prone Exmerge.exe utility. There are also some third party tools which allow the users to export mailboxes to .pst files from both Online and Offline Exchange databases i.e. there is no need to stop the Exchange server before running the tool. One such tool is Stellar Phoenix EDB to PST Converter that supports all versions of MS Exchange Server and quickly exports all or a single Mailbox to .pst file. For detailed information, you may visit here: http://www.edb-pst-converter.com/

Subject: thanks Ben
Posted by: coamiked (view profile)
Posted on: Thursday, June 21, 2012 at 6:06 AM
Message: Thanks Ben...I know this article is a few years old but it is still informative. Pull my --- out of a bind. Keep up the good work

Mike

Subject: Run the command on the top level folder and not the subfolders?
Posted by: curtissw (view profile)
Posted on: Tuesday, January 29, 2013 at 1:56 PM
Message:
I am running this script below and it works fine except for it not only delete’s the files in the inbox but in the subfolders as well. Is there a way to have it just delete the items in the inbox and not the subfolders? I already tried the -ExcludeFolders command and it does not allow both. We already use the built in manage folders for something else and it looks like you can only create one rule per folder.

$today = (get-date).AddDays(-15).ToString("MM/dd/y")
Export-Mailbox -Identity “general" -IncludeFolders "\inbox", "\sent items”, "\deleted items" -EndDate “$today" –DeleteContent -Confirm:$false


Subject: Great Blog with Simple Steps
Posted by: adom503 (view profile)
Posted on: Wednesday, April 24, 2013 at 6:43 AM
Message: Nice steps are here for exporting mailboxes from live exchange to pst. I searched a blog that also saying for exporting mailboxes from offline edb to pst. Read here:

http://www.modernghana.com/blogs/458580/31/export-mailboxes-from-offline-edb-to-pst-or-live-e.html

Subject: Rapid way to Export Exchange Mailbox to Outlook PST
Posted by: suzainsmith (view profile)
Posted on: Thursday, December 05, 2013 at 5:35 AM
Message: There is one more tool that is prevalence from the named as Exchange EDB to PST Software. This Exchange EDB to PST Recovery Tool elegantly repair orphaned Exchange EDB file database without missing a single file of Exchange EDB. This Software rapidly export Exchange EDB to PST with its all attachments.
Get this tool from here-
http://www.edbrecoverytool.org/ http://edbrecoverytopstsoftware.tumblr.com/

Subject: Best tool to recover EDB file to PST
Posted by: kalengarbo (view profile)
Posted on: Tuesday, March 04, 2014 at 1:57 AM
Message: If you are still unable to recover EDB to PST then I suggest you best EDB to PST recovery tool because I got excellent experience with this tool. This is professionally works on EDB file and convert exchange EDB to Outlook with all EDB folders.

Get more info............
http://www.edbtopsts.com/
http://www.edbtopst-software.com/

 

Top Rated

Migrating to Microsoft BPOS - Part II
 In his last article, Johan gave us a crystal clear guide to preparing to migrate from an on-premises... Read more...

Emulating the Exchange 2003 RUS for Out-of-Band Mailbox Provisioning in Exchange 2007
 Exchange's Recipient Update Service was important in Exchange 2000 or 2003 in order to complete the... Read more...

The Postmasters
 The Exchange Team introduces themselves, and keeps you up-to-date Read more...

For this Exchange Server Archiver, “Transparency” Fits
 Sometimes, it is a great relief when a user of your software gives it a tough test and then reports... Read more...

Hunting in Packs, Seamless-ness and Happy Holidays
 I attended DevConnections (Exchange) last month and was blown away by the technical talks. Speakers... Read more...

Most Viewed

Upgrade Exchange 2003 to Exchange 2010
  In this article, the first of two in which Jaap describes how to move from Exchange Server 2003... Read more...

Upgrade Exchange 2003 to Exchange 2010 - Part II
 In Jaap's second article on upgrading straight from Exchange Server 2003 to 2010, he explains how to... Read more...

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... Read more...

Exchange E-mail Addresses and the Outlook Address Cache
 Because Exchange auto-complete cache uses X.500 addresses for e-mail sent to addresses within the... Read more...

Using Exchange 2007 for Resource Booking
 The process of booking various resources to go with a meeting room just got a whole lot easier with... Read more...

Why Join

Over 400,000 Microsoft professionals subscribe to the Simple-Talk technical journal. Join today, it's fast, simple, free and secure.