When you encounter a situation where the transport queues are filling up, or you just want to get messages out of a transport queue for further usage, you must export the messages to the file system.
With Exchange 2007, you could easily utilize the Export-Message cmdlet to export suspended messages from a transport queue:
Get-Message -Queue MYSERVER29489 | ?{$_.Status -eq "Suspended"} | Export-Message -Path D:\MessageExport
With Exchange Server 2010 or newer, the Path attribute had been removed from the Export-Message cmdlet. The cmdlet now returns a binary object that needs to be assembled to a readable text message.
You can only export suspended messages, as the transport service might take precedence on non-suspended messages. You can either suspend the queue or suspend single messages. The following example for Exchange Server 2010 or newer suspends the messages, but not the queue itself.
Identify the queue holding messages to be exported
Beispiel: Auflistung der Warteschlage auf Server MCMEP01
Get-Queue -Server MCMEP01 Identity DeliveryType Status MessageCount Velocity RiskLevel OutboundIPPool NextHopDomain-------- ------------ ------ ------------ -------- --------- -------------- -------------MCMEP0118 SmtpDeliv... Ready 0 0 Normal 0 MXEDB19MCMEP0123 SmtpDeliv... Ready 0 0 Normal 0 MXEDB08MCMEP0124 SmtpDeliv... Ready 0 0 Normal 0 MXEDB01MCMEP0125 SmartHost... Ready 3 0 Normal 0 [10.10.11.1]MCMEP0153 SmtpDeliv... Ready 0 0 Normal 0 MXEDB03MCMEP01Submission Undefined Ready 512 0 Normal 0 SubmissionMCMEP01Shadow3 ShadowRed... Ready 2 0 Normal 0 MCMEP04.mcsmemail.deMCMEP01Shadow4 ShadowRed... Ready 2 0 Normal 0 MCMEP03.mcsmemail.deMCMEP01Shadow5 ShadowRed... Ready 3 0 Normal 0 MCMEP02.mcsmemail.deMCMEP01Shadow6 ShadowRed... Ready 2 0 Normal 0 MCMEP07.mcsmemail.deMCMEP01Shadow15 ShadowRed... Ready 1 0 Normal 0 MCMEP08.mcsmemail.de
Suspend all Messages in Queue MCMEP01Submission
Get-Queue MCMEP01Submission | Get-Message ResultSize Unlimited | Suspend-Message
Fetch all messages to an array and export all messages to the local file system. You can either export all messages by just enumerating the messages or by using the message subject as the file name. Using the message subject posed the risk that the subject might contain a character that is not allowed for file names.
$array = @(Get-Message -Queue MCMEP01Submission -ResultSize Unlimited | ?{$_.Status -eq "Suspened"}) $array | ForEach-Object {$m++;Export-Message $_.Identity | AssembleMessage -Path ("E:Export"+$m+"".eml"")} $array | ForEach-Object {$m++;$filename=""E:\Export\""+$m+""_""+$_.subject+"".eml""; Export-Message $_.identity | AssembleMessage -path $filename}
The messages exported to the local file system can now be copied to the Exchange Transport Replay folder