Export-Mailbox

 

Applies to: Exchange Server 2007 SP1, Exchange Server 2007 SP2, Exchange Server 2007 SP3

Use the Export-Mailbox cmdlet to move the contents of a mailbox to a specified mailbox folder.

Syntax

export-Mailbox -Identity <MailboxIdParameter> [-AllContentKeywords <String[]>] [-AllowDuplicates <SwitchParameter>] [-AttachmentFilenames <String[]>] [-BadItemLimit <Int32>] [-Confirm [<SwitchParameter>]] [-ContentKeywords <String[]>] [-DeleteAssociatedMessages <SwitchParameter>] [-DeleteContent <SwitchParameter>] [-EndDate <DateTime>] [-ExcludeFolders <MapiFolderPath[]>] [-GlobalCatalog <Fqdn>] [-IncludeFolders <MapiFolderPath[]>] [-Locale <CultureInfo>] [-MaxThreads <Int32>] [-RecipientKeywords <String[]>] [-ReportFile <LocalLongFullPath>] [-SenderKeywords <String[]>] [-StartDate <DateTime>] [-SubjectKeywords <String[]>] [-ValidateOnly <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

export-Mailbox -Identity <MailboxIdParameter> -TargetFolder <String> -TargetMailbox <MailboxIdParameter> [-AllContentKeywords <String[]>] [-AllowDuplicates <SwitchParameter>] [-AllowMerge <SwitchParameter>] [-AttachmentFilenames <String[]>] [-BadItemLimit <Int32>] [-Confirm [<SwitchParameter>]] [-ContentKeywords <String[]>] [-DeleteAssociatedMessages <SwitchParameter>] [-DeleteContent <SwitchParameter>] [-EndDate <DateTime>] [-ExcludeFolders <MapiFolderPath[]>] [-GlobalCatalog <Fqdn>] [-IncludeFolders <MapiFolderPath[]>] [-Locale <CultureInfo>] [-MaxThreads <Int32>] [-RecipientKeywords <String[]>] [-ReportFile <LocalLongFullPath>] [-SenderKeywords <String[]>] [-StartDate <DateTime>] [-SubjectKeywords <String[]>] [-ValidateOnly <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

export-Mailbox -Identity <MailboxIdParameter> -PSTFolderPath <LongPath> [-AllContentKeywords <String[]>] [-AllowDuplicates <SwitchParameter>] [-AttachmentFilenames <String[]>] [-BadItemLimit <Int32>] [-Confirm [<SwitchParameter>]] [-ContentKeywords <String[]>] [-DeleteAssociatedMessages <SwitchParameter>] [-DeleteContent <SwitchParameter>] [-EndDate <DateTime>] [-ExcludeFolders <MapiFolderPath[]>] [-GlobalCatalog <Fqdn>] [-IncludeAssociatedMessages <SwitchParameter>] [-IncludeFolders <MapiFolderPath[]>] [-Locale <CultureInfo>] [-MaxThreads <Int32>] [-RecipientKeywords <String[]>] [-ReportFile <LocalLongFullPath>] [-SenderKeywords <String[]>] [-StartDate <DateTime>] [-SubjectKeywords <String[]>] [-ValidateOnly <SwitchParameter>] [-WhatIf [<SwitchParameter>]]

Detailed Description

To run the Export-Mailbox cmdlet, the account you use must be delegated the following:

  • Exchange Server Administrator role and local Administrators group for 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 Microsoft Exchange Server 2007, see Permission Considerations.

To grant full access to a mailbox, use the Add-MailboxPermission cmdlet and specify FullAccess for the AccessRights parameter.

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 can use the Export-Mailbox cmdlet to export data to either a folder or a .pst file. The source and target mailboxes must be on one of the following:

  • Exchange 2007 server

  • Exchange Server 2003 Service Pack 2 (SP2) (or later versions) server

  • Exchange 2000 Server Service Pack 3 (SP3) (or later versions) server

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

  • Microsoft Office Outlook 2003 SP2 or later versions

Note

Microsoft Knowledge Base articles 289999 and 813593 describe a problem with using Outlook 2003 to delete several objects from a folder. You cannot use the Export-Mailbox cmdlet to delete more than 4,000 objects from a folder. To export more objects, you must use Outlook 2007.

For Exchange 2007 management tools 32-bit download information, see Microsoft Exchange Server 2007 Management Tools (32-Bit).

You cannot export data to a .pst file from a mailbox that is in a recovery storage group (RSG).

You cannot export data from a public folder database.

The Export-Mailbox cmdlet exports all empty folders and special folders to the target location. The special folders are the following:

  • Inbox

  • Deleted Items

  • Drafts

  • Junk E-Mail

  • Outbox

  • Sent Items

  • Journal

  • Calendar

  • Contacts

  • Notes

  • Tasks

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.

If you export data to another mailbox by using the TargetMailbox parameter, the Export-Mailbox cmdlet also exports messages from the dumpster of Deleted Items. The messages from the dumpster are converted to regular messages when they are exported.

Note

If you use any keyword parameters, Export-Mailbox 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 on the target mailbox and will also be searched for keywords. Export-Mailbox 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 dumpster, see How to Recover a Deleted Item.

Parameters

Parameter Required Type Description

Identity

Required

Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter

The Identity parameter specifies the mailbox from which to export contents. You can use the following values:

  • Alias

  • Simple Mail Transfer Protocol (SMTP) address

  • Display name

If the Get-Mailbox command object is piped, this parameter is not required.

PSTFolderPath

Required

Microsoft.Exchange.Data.LongPath

The PSTFolderPath parameter specifies the path of the .pst file to which data will be exported.

TargetFolder

Required

System.String

The TargetFolder parameter specifies the top-level mailbox folder that will be created on the mailbox specified by the TargetMailbox parameter. This folder will contain a subfolder called Recovered Data - <source mailbox alias> - <date time stamp>. The subfolder contains the exported data. 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.

TargetMailbox

Required

Microsoft.Exchange.Configuration.Tasks.MailboxIdParameter

The TargetMailbox parameter specifies the mailbox where the target folder will be created. The mailbox that you specify must exist for the command to complete successfully.

AllContentKeywords

Optional

System.String[]

The AllContentKeywords parameter specifies the keywords of the content to include in the move. If the command finds a keyword that you specify in the message body, attachment content, or subject, it will export those messages.

The buffer for the AllContentKeywords parameter is 32 kilobytes.

Note

This is different from using both the ContentKeywords and SubjectKeywords parameters. If you use both the ContentKeywords and SubjectKeywords parameters, the command will export only those messages that have both the keyword that you specify for the ContentKeywords parameter in the message body or attachment content, and the keyword you specify for the SubjectKeywords parameter in the subject.

AllowDuplicates

Optional

System.Management.Automation.SwitchParameter

The AllowDuplicates parameter is used to copy mail items without checking if they are duplicates of existing items and without removing duplicate items. We recommend that you use the AllowDuplicates parameter together with the IncludeFolders parameter.

AllowMerge

Optional

System.Management.Automation.SwitchParameter

The AllowMerge parameter specifies that the content that is exported will be merged into the target folder to avoid duplicates. If you specify the AllowMerge parameter, the name of the subfolder to which content is exported will not include a date-time stamp. You can export data to the same target folder and subfolder multiple times by using the AllowMerge parameter.

AttachmentFilenames

Optional

System.String[]

The AttachmentFilenames parameter specifies the filter for attachments. You can use wildcard characters in the string. For example, you can use "*.txt" to export items that have a .txt extension.

BadItemLimit

Optional

System.Int32

The BadItemLimit parameter specifies the number of corrupted items in a mailbox to skip before the export operation fails.

Confirm

Optional

System.Management.Automation.SwitchParameter

The Confirm parameter causes the command to pause processing and requires you to acknowledge what the command will do before processing continues. You do not have to specify a value with the Confirm parameter.

ContentKeywords

Optional

System.String[]

The ContentKeywords parameter specifies the keywords of the content to include in the move. If the command finds a keyword that you specify in the message body or in the attachment content, it will export those messages.

DeleteAssociatedMessages

Optional

System.Management.Automation.SwitchParameter

The DeleteAssociatedMessages parameter specifies that associated messages will be deleted. Associated messages contain hidden data with information about rules, views, and forms.

If you use the DeleteAssociatedMessages parameter and do not specify a TargetMailbox and TargetFolder, or a PSTFolderPath, no content will be exported.

DeleteContent

Optional

System.Management.Automation.SwitchParameter

The DeleteContent parameter specifies the option to delete the content from the source mailbox after it has been exported to a folder. The source folder will not be deleted.

EndDate

Optional

System.DateTime

The EndDate parameter specifies the end date for filtering content that will be exported from the source mailbox. Only items in the mailbox whose date is prior to or the same as the end date will be exported. When you enter a specific date, use the short date format that is defined in the Regional Options settings that are configured on the local computer. For example, if your computer is configured to use the short date format mm/dd/yyyy, enter 03/01/2006 to specify March 1, 2006.

ExcludeFolders

Optional

Microsoft.Exchange.Data.Mapi.MapiFolderPath[]

The ExcludeFolders parameter specifies the list of folders to exclude during the export.

GlobalCatalog

Optional

Microsoft.Exchange.Data.Fqdn

The GlobalCatalog parameter specifies the global catalog to use to search for the target mailbox.

IncludeAssociatedMessages

Optional

System.Management.Automation.SwitchParameter

The IncludeAssociatedMessages parameter specifies that associated messages will be included in the export. Associated messages contain hidden data with information about rules, views, and forms. By default, associated messages are not included in an export.

IncludeFolders

Optional

Microsoft.Exchange.Data.Mapi.MapiFolderPath[]

The IncludeFolders parameter specifies the list of folders to include during the export.

Locale

Optional

System.Globalization.CultureInfo

The Locale parameter specifies the locale of messages to export. The command will export only messages with the locale that you specify.

MaxThreads

Optional

System.Int32

The MaxThreads parameter specifies the maximum number of threads to use. The default value is 4.

RecipientKeywords

Optional

System.String[]

The RecipientKeywords parameter specifies recipient e-mail addresses or display names. If the command finds a message with a recipient that is the same as the recipient keyword that you specified, it will export the message.

If the recipient keyword that you specify is the same as a distribution group that is a recipient of a message, the message will be exported. The command does not expand distribution groups to compare the recipient keywords that you specify to the members of a distribution group that is a recipient of a message.

ReportFile

Optional

Microsoft.Exchange.Data.LocalLongFullPath

The ReportFile parameter specifies the path and file name for the XML report log.

SenderKeywords

Optional

System.String[]

The SenderKeywords parameter specifies sender e-mail addresses or display names. If the command finds a message with a sender that is the same as a sender keyword that you specify, it will export the message.

StartDate

Optional

System.DateTime

The StartDate parameter specifies the start date for filtering content that will be exported from the source mailbox. Only items in the mailbox whose date is later than the start date will be exported. When you enter a specific date, use the short date format that is defined in the Regional Options settings that are configured on the local computer. For example, if your computer is configured to use the short date format mm/dd/yyyy, enter 03/01/2006 to specify March 1, 2006.

SubjectKeywords

Optional

System.String[]

The SubjectKeywords parameter specifies the keyword filters for subjects of items in the source mailbox.

ValidateOnly

Optional

System.Management.Automation.SwitchParameter

The ValidateOnly parameter provides the option to validate the export without exporting the data. The ValidateOnly parameter validates any prerequisites for the command.

Note

If you run the Export-Mailbox command with this parameter, the command will not apply any filters to the messages. It will only check if the source and target mailboxes exist.

WhatIf

Optional

System.Management.Automation.SwitchParameter

The WhatIf parameter instructs the command to simulate the actions that it would take on the object. By using the WhatIf parameter, you can view what changes would occur without having to apply any of those changes. You do not have to specify a value with the WhatIf parameter.

Input Types

Return Types

Errors

Error Description

 

Exceptions

Exceptions Description

 

Example

The first example shows how to export the contents of the mailbox of user john@contoso.com to the folder MyData on the mailbox ExportMailbox.

The second example shows how to use filters to specify which items in the source mailbox to include in the export. This example exports all items from the mailbox of user contoso\john that have the keyword "merger" in the message body or in the content of an attachment, have an attachment that is named *orgchart*, and have a date that is later than 03/01/2006 at 12:01:00 A.M.

The third example shows how to find and delete items from a mailbox. This example first gets all the mailboxes on database DB1 and searches for items that contain the string "Virus message" in the subject. It will export the items to another mailbox and will delete those items from the source mailbox.

The fourth example shows that you can pipe the output from the Get-User command to the Export-Mailbox command. This example also excludes two folders from the export. The items in the Junk E-Mail and Contacts folders in John's mailbox will not be exported to the ExportMailbox.

Note

You can also pipe the output from Get-Recipient or Get-Mailbox to Export-Mailbox.

The fifth example shows how to export the contents of the mailbox of user john@contoso.com to a .pst file called john.pst located at C:\PSTFiles.

The sixth example shows how to export data from all the mailboxes of users in the Marketing organizational unit. The data from each mailbox will be exported to a separate .pst file located at C:\PSTFiles. The name of each .pst file will be <alias>.pst. The messages that will be exported are those whose recipients include either tony@fabrikam.com or christine@fabrikam.com.

Export-Mailbox -Identity john@contoso.com -TargetMailbox ExportMailbox -TargetFolder MyData
Export-Mailbox -Identity contoso\john -TargetMailbox ExportMailbox -TargetFolder MyData -ContentKeywords "merger" -AttachmentFilenames "*orgchart*" -StartDate "03/01/2006 12:01:00"
Get-Mailbox -Database DB1 | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder VirusData -SubjectKeywords "Virus message" -DeleteContent
Get-User john | Export-Mailbox -TargetMailbox ExportMailbox -TargetFolder MyData -ExcludeFolders "\Junk E-Mail","\Contacts"
Export-Mailbox -Identity john@contoso.com -PSTFolderPath C:\PSTFiles\john.pst
Get-Mailbox -OrganizationalUnit Marketing | Export-Mailbox -PSTFolderPath C:\PSTFiles -RecipientKeywords "tony@fabrikam.com","christine@fabrikam.com"