Applies to: Exchange Server 2010 SP3, Exchange Server 2010 SP2

Topic Last Modified: 2012-10-30

You can use the Shell to export messages from a queue on a computer that has the Microsoft Exchange Server 2010 Hub Transport server role or the Edge Transport server role installed to a specified file path. You can't use Queue Viewer to perform this task. However, you can use Queue Viewer to locate, identify, and suspend the messages before you perform this task.

When you export a message from a queue to a file, the message isn't removed from the queue. A copy of the message is made in the specified location as a plain text file. The resulting file can be viewed in an application, such as a text editor or an e-mail client application, or the message file can be resubmitted by using the Replay directory on any other Hub Transport server or Edge Transport server inside or outside the Exchange organization.

Looking for other management tasks related to managing transport queues? Check out Managing Transport Queues.

Prerequisites

Before you export a message from a queue, you must follow these steps:

  1. Verify the following information about the target directory location:

    • The target directory must exist before you export any messages. The directory won't be created for you. If an absolute path isn't specified, the current Shell working directory is used.

    • The path may be local to the Exchange 2010 computer, or it may be a Universal Naming Convention (UNC) path to a share on a remote server.

    • Your account must have the Write permission to the target directory.

  2. Locate and identify the messages to be exported. For information about how to view messages, see View Queued Message Properties.

  3. Suspend the messages to be exported to prevent their delivery during the export process. The messages must be in a suspended state for the export process to be successful. You can export messages from remote delivery queues, mailbox delivery queues, the Unreachable queue, or the poison message queue. Messages in the poison message queue are already in a suspended state. You can't suspend or export messages that are in the Submission queue. For information about how to suspend messages, see Suspend Messages.

  4. When you specify a file name, make sure that you include the .eml file name extension so that the file can be opened easily by e-mail client applications or processed correctly by the Replay directory.

Use the Shell to export a specific message from a specific queue

You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Queues" entry in the Transport Permissions topic.

Note:
You can't use the EMC to perform this task.

This example exports a copy of a message that has an InternalMessageID of 1234 that's located in the remote delivery queue for the domain Contoso.com on the server Exchange01 to the path C:\Contoso Export\export.eml.

Copy Code
Export-Message -Identity ExchSrv1\contoso.com\1234 | AssembleMessage -Path "c:\exportfolder\filename.eml"

For detailed syntax and parameter information, see Export-Message.

Use the Shell to export all messages from a specific queue

You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Queues" entry in the Transport Permissions topic.

Note:
You can't use the EMC to perform this task.

This example exports a copy of all the messages from the Contoso.com remote delivery queue on the server Exchange01 to the directory C:\Contoso Export on the local computer using the Internet Message IDs of each message as the file name. To accomplish this, the command does the following:

  • Retrieves all messages in a specific queue using the Get-Message cmdlet.

  • Pipelines the result into the ForEach-Object cmdlet, which executes the following actions for each message:

    • Prepares a file name including full path using the temporary variable $Temp that consists of the Internet Message ID with .eml extension. The Internet Message ID field contains angled brackets (> and <), which need to be removed because they're invalid file names. This is done using the Replace method of the temporary variable.

    • Exports the message using the file name prepared.

Copy Code
Get-Message -Queue "Exchange01\Contoso.com" | ForEach-Object {$Temp="C:\Contoso Export\"+$_.InternetMessageID+".eml";$Temp=$Temp.Replace("<","_");$Temp=$Temp.Replace(">","_");Export-Message $_.Identity | AssembleMessage -Path $Temp}

For detailed syntax and parameter information, see the Get-Message and Export-Message topics.

Use the Shell to export specific messages from all the queues on a server

You need to be assigned permissions before you can perform this procedure. To see what permissions you need, see the "Queues" entry in the Transport Permissions topic.

Note:
You can't use the EMC to perform this task.

This example exports a copy of all the messages from senders in the Contoso.com domain from all queues on the server Exchange01 to the directory C:\Contoso Export on the local computer using the Internet Message IDs of each message as the file name. To accomplish this, the command does the following:

  • Retrieves all messages that match the criteria using the Get-Message cmdlet with a filter.

  • Pipelines the result into the ForEach-Object cmdlet, which executes the following actions for each message:

    • Prepares a file name including full path using the temporary variable $Temp that consists of the Internet Message ID with .eml extension. The Internet Message ID field contains angled brackets (> and <), which need to be removed because they're invalid file names. This is done using the Replace method of the temporary variable.

    • Exports the message using the file name prepared.

Copy Code
Get-Message -Filter {FromAddress -like "@Contoso.com"} -Server "Exchange01" | ForEach-Object {$Temp="C:\Contoso Export\"+$_.InternetMessageID+".eml";$Temp=$Temp.Replace("<","_");$Temp=$Temp.Replace(">","_");Export-Message $_.Identity | AssembleMessage -Path $Temp}

For detailed syntax and parameter information, see the Get-Message and Export-Message topics.