Click to Rate and Give Feedback
TechNet
TechNet Library
Exchange Server
Operations
Managing Recipients
 How to Export Mailbox Data

  Switch on low bandwidth view
How to Export Mailbox Data

Applies to: Exchange Server 2007 SP1, Exchange Server 2007 Topic Last Modified: 2007-08-21

This topic explains how to use the Exchange Management Shell to export mailbox data from one mailbox to a folder in another mailbox.

Bb266964.note(en-us,EXCHG.80).gifNote:
You cannot use the Exchange Management Console to export mailbox data.

You cannot export data from a mailbox in one forest to a mailbox in a different forest. The source and target mailboxes must be in the same forest.

You cannot export data from a public folder database.

Exchange 2007 SP1 introduces the following functionality for exporting mailbox data:

  • You can export mailbox data from a mailbox to a .pst file. To export to a .pst file, you must use the PSTFolderPath parameter to specify the path to the .pst file to which data will be exported.
    You can use the Export-Mailbox cmdlet to export data to either a folder or a .pst file. The source and target mailboxes must exist on a server that is running one of the following versions of Microsoft Exchange:
    • Exchange Server 2007
    • Exchange Server 2003 SP2 or a later version
    • Exchange 2000 Server SP3 or a later version
    You cannot export data to a .pst file from a mailbox that is in a recovery storage group (RSG).
  • You can merge the data that you export into an existing target folder by using the AllowMerge parameter.
  • You can use the Export-Mailbox cmdlet to delete associated messages or to include associated messages in the export process. Associated messages contain hidden data with information about rules, views, and forms.
  • If you use the DeleteContent parameter and do not specify the TargetMailbox parameter, you can delete content from the source mailbox without exporting it to another mailbox.
  • You can filter the messages that are exported based on recipients and senders. To filter on recipients, use the RecipientKeywords parameter. To filter on the sender, use the SenderKeywords parameter.

By default, the Export-Mailbox cmdlet exports all empty folders, special folders, and subfolders to the target location. To specify folders to either include in or exclude from the export, use the IncludeFolders or ExcludeFolders parameter. The special folders include:

  • Inbox
  • Deleted Items
  • Drafts
  • Junk E-Mail
  • Outbox
  • Sent Items
  • Journal
  • Calendar
  • Contacts
  • Notes
  • Tasks

The Export-Mailbox cmdlet exports all message types, including messages, calendar items, contacts, distribution lists, journal entries, tasks, notes, and documents.

The Export-Mailbox cmdlet also exports messages from the dumpster. Messages from the dumpster are converted to regular items in the folder or .pst file to which you export data.

Bb266964.note(en-us,EXCHG.80).gifNote:
If you use any keyword parameters, the Export-Mailbox cmdlet will first export all of the messages, including messages in the dumpster, and then search the target mailbox for messages that meet the keyword criteria. Messages that were in the dumpster on the source mailbox are converted to regular messages in the Deleted Items folder on the target mailbox and will also be searched for keywords. The Export-Mailbox cmdlet then deletes messages on the target mailbox that do not match the keyword criteria. If you also use the DeleteContent parameter, Export-Mailbox will then delete the messages that match the keyword criteria from the source mailbox.

For more information about messages in the transport dumpster, see How to Recover a Deleted Item.

The Export-Mailbox cmdlet does not export rules.

You must specify a destination mailbox by using the TargetMailbox parameter. You must also specify a folder on the destination mailbox where you want to export data by using the TargetFolder parameter. The TargetFolder parameter specifies the top-level mailbox folder that will be created on the destination mailbox. This folder will contain a subfolder called Recovered Data - <source mailbox alias> - <date time stamp>. The subfolder contains the exported folders and messages within those folders.

Bb266964.note(en-us,EXCHG.80).gifNote:
In Exchange 2007 SP1, if you specify the AllowMerge parameter, the name of the subfolder will not include a date-time stamp.
Bb266964.note(en-us,EXCHG.80).gifNote:
In Exchange 2007 SP1, you can specify a path to a .pst file to which data will be exported instead of specifying a target mailbox and target folder.

If the target folder that you specify already exists on the target mailbox, the exported data will be added to the existing folder. If the target folder does not exist, it will be created.

To perform this procedure, the account you use must be delegated the following:

  • Exchange Server Administrators role and local Administrators group for the source server and the target server
  • Full access to the source and target mailboxes

For more information about permissions, delegating roles, and the rights that are required to administer Exchange 2007, see Permission Considerations.

Also, before you perform this procedure, be aware of the following:

  • To grant full access to a mailbox, use the Add-MailboxPermission cmdlet and specify FullAccess for the AccessRights parameter. For example, if Admin01 needs to export data from John's mailbox to a mailbox called Export, you must first run the following commands:
    Add-MailboxPermission -Identity john -User Admin01 -AccessRights FullAccess
    Add-MailboxPermission -Identity Export -User Admin01 -AccessRights FullAccess
  • To export data from an Exchange 2003 or Exchange 2000 mailbox, the account you use must be delegated the Exchange Administrator role for the administrative group in which the server resides.
  • To export data from a .pst file, you must run the Export-Mailbox cmdlet from a 32-bit computer that has the following installed:
    • The 32-bit version of the Exchange management tools
    • Outlook 2003 Service Pack 2 (SP2) or Outlook 2007
    For information about Exchange 2007 management tools 32-bit download, see Microsoft Exchange Server 2007 Management Tools (32-Bit).
  • If you export data to a folder in another mailbox, the target mailbox that you specify must exist before you run the command.

Exchange 2007 SP1

  • To export the special folders and empty folders of the mailbox user John to a folder called MyData on the mailbox ExportMailbox, run the following command:

    Export-Mailbox -Identity john@contoso.com -TargetMailbox ExportMailbox -TargetFolder MyData
  • To export data to a .pst file called john.pst located at C:\PSTFiles, run the following command:

    Export-Mailbox -Identity john@contoso.com -PSTFolderPath C:\PSTFiles\john.pst
  • To export data from a group of mailboxes, such as all mailboxes for which the user title begins with "VP," run the following command:

    Get-User | where { $_.Title -ilike "VP*" } | Export-Mailbox -TargetFolder VPData -TargetMailbox ExportMailbox
  • To export data that was received between February 2, 2005, and February 15, 2005, to a .pst file, run the following command:

    Export-Mailbox -Id john@contoso.com -StartDate "02/02/05" -EndDate "02/15/05" -PSTFolderPath C:\PSTFiles\john.pst
  • To export only data from the Sent Items folder, run the following command:

    Export-Mailbox -Id john -IncludeFolders '\Sent Items' -TargetFolder 'John Sent Items' -TargetMailbox ExportMailbox
  • To exclude folders from the export, such as excluding items in the Junk E-Mail and Contacts folders, run the following command:

    Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder MyData -ExcludeFolders "\Junk E-Mail","\Contacts"
  • To use filters to specify which items in the source mailbox to include in the export, run the following command:

    Export-Mailbox -Identity contoso\john -TargetMailbox ExportMailbox -TargetFolder MyData -ContentKeywords "merger" -AttachmentFilenames "*orgchart*" -StartDate "03/01/2006 12:01:00" -RecipientKeywords tony@fabrikam.com

    This example exports all items from the mailbox user contoso\john that meet the following criteria:

    • Contain the keyword "merger" in the message body or in the content of an attachment.
    • Have an attachment that is named *orgchart*.
    • Are dated later than 03/01/2006 at 12:01:00 A.M.
    • Have tony@fabrikam.com as one of the recipients.
  • To find and delete items from a group of mailboxes, such as all mailboxes on a database, run the following command:

    Get-Mailbox -Database DB1 | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder VirusData -SubjectKeywords "Virus message" -DeleteContent

    This example first gets all the mailboxes on database DB1 and then searches for items that contain the string "Virus message" in the subject line. It will export the items to the mailbox ExportMailbox and will delete those items from the source mailbox.

  • To find and delete items from a group of mailboxes, such as all mailboxes on a database, without exporting the items to another mailbox, run the following command:

    Get-Mailbox -Database DB1 | Export-Mailbox -SubjectKeywords "Virus message" -DeleteContent

    This example first gets all the mailboxes on database DB1, searches for items that contain the string "Virus message" in the subject, and deletes those items.

  • To export data from all the mailboxes of users in the Marketing organizational unit, run the following command:

    Get-Mailbox -OrganizationalUnit Marketing | Export-Mailbox -PSTFolderPath C:\PSTFiles

    This example exports the data from each mailbox to a separate .pst file located at C:\PSTFiles. The name of each .pst file will be <alias>.pst.

Exchange 2007 RTM

  • To export the special folders and empty folders to a folder called MyData on the mailbox ExportMailbox, run the following command:

    Export-Mailbox -Identity john@contoso.com -TargetMailbox ExportMailbox -TargetFolder MyData
  • To export data from a group of mailboxes, such as all mailboxes for which the user title begins with "VP," run the following command:

    Get-User | where { $_.Title -ilike "VP*" } | Export-Mailbox -TargetFolder VPData -TargetMailbox ExportMailbox
  • To export data received between February 2, 2005, and February 15, 2005, run the following command:

    Export-Mailbox -Id john@contoso.com -StartDate "02/02/05" -EndDate "02/15/05" -TargetFolder MyData -TargetMailbox ExportMailbox
  • To export only data from the Sent Items folder, run the following command:

    Export-Mailbox -Id john -IncludeFolders '\Sent Items' -TargetFolder 'John Sent Items' -TargetMailbox ExportMailbox
  • To exclude folders from the export, such as excluding items in the Junk E-Mail and Contacts folders, run the following command:

    Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder MyData -ExcludeFolders "\Junk E-Mail","\Contacts"
  • To use filters to specify which items in the source mailbox to include in the export, run the following command:

    Export-Mailbox -Identity contoso\john -TargetMailbox ExportMailbox -TargetFolder MyData -ContentKeywords "merger" -AttachmentFilenames "*orgchart*" -StartDate "03/01/2006 12:01:00"

    This example exports all items from the mailbox user contoso\john that:

    • Contain the keyword "merger" in the message body or in the content of an attachment.
    • Have an attachment that is named *orgchart*.
    • Is dated later than 03/01/2006 at 12:01:00 A.M.
  • To find and delete items from a group of mailboxes, such as all mailboxes on a database, run the following command:

    Get-Mailbox -Database DB1 | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder VirusData -SubjectKeywords "Virus message" -DeleteContent

    This example first gets all the mailboxes on database DB1 and then searches for items that contain the string "Virus message" in the subject. It will export the items to the mailbox ExportMailbox and will delete those items from the source mailbox.

For detailed syntax and parameter information, see the Export-Mailbox (RTM) reference topic.

In Exchange 2003 or Exchange 2000, you can use the Microsoft Exchange Server Mailbox Merge wizard (ExMerge.exe) to export mailbox data. The following table lists scenarios for using ExMerge.exe in Exchange 2003 or Exchange 2000, and the solution for performing this task in Exchange 2007.

Scenario in Exchange 2003 and Exchange 2000 Exchange 2003 and Exchange 2000 resources Exchange 2007 solution

Use ExMerge.exe in Exchange 2003 or Exchange 2000 in recovery scenarios to move the recovered data from the recovery storage group to another database.

To perform this task in Exchange 2007, use the Restore-Mailbox cmdlet. For more information, see How to Recover a Mailbox by Using a Recovery Storage Group.

Use ExMerge.exe in Exchange 2003 or Exchange 2000 to export user data from a corrupted database to a .pst file, and then from the .pst file to a new database.

For information about the Exchange 2003 or Exchange 2000 scenario, see Microsoft Knowledge Base article 313184, How to recover the information store on Exchange 2000 Server or Exchange Server 2003 in a single site.

To perform this task in Exchange 2007, use the Restore-Mailbox cmdlet to restore the data from backup, and then use the Move-Mailbox cmdlet. For more information, see Restore-Mailbox and Move-Mailbox.

Use ExMerge.exe in Exchange 2003 or Exchange 2000 to move mailboxes to a different server.

For information about the Exchange 2003 or Exchange 2000 scenario, see Microsoft Knowledge Base article 328810, Moving mailboxes between servers.

To perform this task in Exchange 2007, use either the Move Mailbox wizard or the Move-Mailbox cmdlet. For more information, see How to Move a Mailbox Within a Single Forest or How to Move a Mailbox Across Forests.

Use ExMerge.exe in Exchange 2003 or Exchange 2000 to remove a specific message that was sent to users in your Exchange organization. For example, you may want to delete a virus message or a confidential message that was sent inadvertently.

For more information about the Exchange 2003 or Exchange 2000 scenario, see Microsoft Knowledge Base article 328202, HOW TO: Remove a Virus-Infected Message from Mailboxes by Using the ExMerge.exe Tool.

To perform this task in Exchange 2007, use the Export-Mailbox cmdlet with the DeleteContent parameter and any of the content filtering parameters, such as AllContentKeywords, AttachmentFilenames, ContentKeywords, SubjectKeywords, StartDate, or EndDate. For more information, see Export-Mailbox.

Use ExMerge.exe in Exchange 2003 or Exchange 2000 to find a specific message that was sent to users in your Exchange organization, or to find all messages with specific words in the subject, message body, or attachments.

For more information about the Exchange 2003 or Exchange 2000 scenario, see Microsoft Knowledge Base article 246916, XADM: How to Find Mailboxes That Contain a Specific Message.

To perform this task in Exchange 2007, use the Export-Mailbox cmdlet with any of the content filtering parameters, such as AllContentKeywords, AttachmentFilenames, ContentKeywords, SubjectKeywords, StartDate, or EndDate, but without the DeleteContent parameter. For more information, see Export-Mailbox.

Use ExMerge.exe in Exchange 2003 or Exchange 2000 as an alternative way to restore mailbox data if you have problems during a mailbox move.

None

To perform this task in Exchange 2007, use the Restore-Mailbox cmdlet to restore mailbox data, and use the Move-Mailbox cmdlet to move mailboxes. For more information, see Restore-Mailbox and Move-Mailbox.

Use ExMerge.exe in Exchange 2003 or Exchange 2000 to export data to a .pst file. For example, if you are in a hosting scenario, you may want to send mailbox content to a former user in the organization.

None

To perform this task in Exchange 2007 SP1, use the PSTFolderPath parameter.

To perform this task in Exchange 2007 RTM, you have two options:

  • Log on to the mailbox that is running Microsoft Outlook, and then use Outlook to export the data to a .pst file.
  • Use the Export-Mailbox cmdlet to export the data from several mailboxes to a single, separate mailbox, and then log on to that mailbox and use Outlook to export the data to a .pst file. For more information about this scenario, see the Exchange Server Team Blog article Exchange Server 2007 Export Mailbox task.
    Bb266964.note(en-us,EXCHG.80).gifNote:
    The content of each blog and its URL are subject to change without notice. The content within each blog is provided "AS IS" with no warranties, and confers no rights. Use of included script samples or code is subject to the terms specified in the Microsoft Terms of Use.

For more information about importing mailbox data from a .pst file, see How to Import Mailbox Data.

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Deleteing emails???      nironixon   |   Edit   |   Show History

Hi there, i have now for hours trying to delete emails from an inbox:

[PS] U:\>Add-MailboxPermission -Identity support -User myAccount -AccessRights FullAccess

Where "myAccount" is my current domain login / mail account.[PS] U:\>Export-Mailbox -Identity "support" -DeleteContent -StartDate "01/12/2008" -EndDate "01/01/2009"

However, i keep getting the same error message:

Export-Mailbox : Error was found for Support (xxxx) because: Err
or occurred in the step: Moving messages. Failed to copy messages to the destin
ation mailbox store with error: An unknown error has occurred., error code: -10
56749164
At line:1 char:15
+ Export-Mailbox <<<< -Identity "support" -DeleteContent -StartDate "01/12/200
8" -EndDate "01/01/2009"

I have service pack 1 and Rollup 5 installed.

Anyone have been more successfull than me?

Tags What's this?: Add a tag
Flag as ContentBug
Delete Folders after export ?      TheOtherDude   |   Edit   |   Show History
Hi, I successfully run

export-mailbox -id INVUSERID -PSTFolderPath E:\TEMP\USERID.pst -DeleteContent -confirm:$false

and the items as messages, tasks, calendar entries all get's deleted after export. However, the folder structure stays in there and hence recover from deleted items is still possible. How can I delete the folder "Recovered Data - USER ID - DATE" from the INVUSERID inbox after export or with an additional cmdlet ???
Tags What's this?: Add a tag
Flag as ContentBug
@nironixon - Deleting emails      WileyIain   |   Edit   |   Show History
Hi, you don't seem to have specified a location for the exported mails to go to. You need to put in either a -TargetMailbox or a -PSTFolderPath parameter. I don't think the command will work at all if you don't give it a location to send the files to as it's an export command, not a delete command.

I guess that as you no longer need these messages, you should do something like this:

Export-Mailbox -Identity "support" -PSTFolderPath c:\deletedmail.pst -DeleteContent -StartDate "01/12/2008" -EndDate "01/01/2009"

Once this has run then you can delete the PST and the mails will be gone.

Tags What's this?: Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker