Saturday, April 13, 2013

Exporting Queue Messages

When exporting messages from a Queue, you need to use the AssembleMessage script. For example, if you want to export the message with message ID 6789 from the letsexchange.com queue on server MBX1, you need to run the following cmdlet:
Export-Message MBX1\letsexchange.com\6789 | AssembleMessage -Path "D:\Messages\Message6789.eml"

To export all messages from a Queue into individual .eml files, use the following script (which you can convert to a one-liner):
Get-Message -Queue "MBX1\letsexchange.com" | ForEach {
  # Build message path and filename with the Internet Message ID as the file name
  $Temp = "D:\Messages\" + $_.InternetMessageID + ".eml"
  $Temp = $Temp.Replace("<", "_")
  $Temp = $Temp.Replace(">", "_")
  
  # Export the message using
  Export-Message $_.Identity | AssembleMessage -Path $Temp
}

No comments:

Post a Comment