Pages

Saturday 20 August 2011

How to Export Exchange 2010 Queues

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.

Messages that get ‘stuck’ in a queue can be exported to a folder and you can later resubmit the messages once you fix the mail flow problem. To export a message (or all messages in a queue) you should first suspend the queue. Suspension does not prevent messages entering the queue, but it will stop them leaving. The following cmdlet suspends the queue.

[PS] Get-TransportServer | Get-Queue

This command will show you the queues on your transport servers (you may have more than one in your site).

You might have an example where your messages are failing to be sent because of name resolution:

 

q1

 

You can see that the DeliveryType is set to DNSConnectorDelivery. The messages are queued for delivery to an external recipient by using an SMTP connector that's located on the local server and that's configured to use Domain Name System (DNS) for routing resolution.

To export the messages, first suspend the queue:

[PS] Suspend-Queue –Identity SRV1\20

Now that the queue is suspended you suspend the messages.

[PS]Get-Queue -Identity srv1\20 | Get-Message -ResultSize unlimited | Suspend-Message –Confirm:$False

-ResultSize unlimited is used as the default is set to 1000.

Now the messages are suspended you can export them. To see the list of messages in the queue type the following:

[PS] Get-Queue -Identity srv1\20 | Get-Message -ResultSize unlimited

The status should show the messages are suspended and you should see the Email subject heading and from address. Notice how the message ID is created and includes the Queue ID.

Now to export a single message:

[PS] Get-Message -Identity srv1\20\75 | AssembleMessage -Path c:\exportfolder\email1

 

To export all the messages from the queue is a bit more complicated. Try the following:

  • [PS] $array = @(Get-Message -Queue srv222\20 -ResultSize unlimited)
  • [PS] $array | ForEach-Object {$i++;Export-Message $_.Identity | AssembleMessage -Path ("c:\exportfolder\"+ $i +".eml")}

The above cmdlets will produce .eml files in c:\exportfolder\ with names like 1.eml, 2.eml. At a later stage you can ‘import’ the messages back into the submission queue by using the replay directory. The Replay directory receives messages from foreign gateway servers and can also be used to resubmit messages that administrators export from the queues of Exchange 2010 servers. Read this post for more.

2 comments:

  1. Just what the doctor ordered, Thanks!

    ReplyDelete
  2. Thank you very much. most appreciated

    ReplyDelete