How to use receive-msmqueue

Topics: User Forum
Jun 27, 2011 at 7:35 AM

I'm trying to use the receive-msmqueue cmd-let and have some problems doing so. The problem is what formatter I should use to get it to work. I see no examples so I don't really know what to enter as parameter

I'm trying to run the command as written below:

Receive-MSMQueue -Formatter 'System.Messaging.XmlMessageFormatter' -Path '<mypath>'

I get the following error when I run the command above:

Receive-MSMQueue : Cannot find a formatter capable of reading this message.At line:1 char:17+ Receive-MSMQueue <<<<  -Formatter 'System.Messaging.XmlMessageFormatter' -Path 'formatname:direct=os:hs-w0531\private$\test1'    + CategoryInfo          : ReadError: (:) [Receive-MSMQueue], InvalidOperationException    + FullyQualifiedErrorId : ReceiveFailed,Pscx.Commands.Messaging.ReceiveMSMQueue 

 

The message on top in the queue gets removed when I run this so the queuename is Ok I guess.

 

What I really want is to automatically save all messages in a queue and remove them from the queue so that I later can restore them into the queue i the right order.

I figured I could read them with Receive-MSMQueue, store the messages in a file and then later read them and put them back(in the right order of course).

Am I way out of line or how should I get this going? 

Sep 10, 2014 at 5:57 PM
Edited Sep 10, 2014 at 5:58 PM
Did you get this to work?

I'm getting a similar error trying to use this to export the messages from a queue on a Win2008 server.
  Receive-MSMQueue -MachineName premsq -Name pdktemp

  Receive-MSMQueue : Cannot find a formatter capable of reading this message.
  At line:1 char:1
  + Receive-MSMQueue -MachineName premsq -Name pdktemp
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ReadError: (:) [Receive-MSMQueue], InvalidOperationException
      + FullyQualifiedErrorId : ReceiveFailed,Pscx.Commands.Messaging.ReceiveMSMQueue
After seeing your post I tried adding a formatter switch, but still get an error.
  Receive-MSMQueue -MachineName premsq -Name pdktemp -Formatter System.Messaging.XmlMessageFormatter

  Receive-MSMQueue : Cannot find a formatter capable of reading this message.
  At line:1 char:1
  + Receive-MSMQueue -MachineName premsq -Name pdktemp -Formatter System.Messaging.X ...
  + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ReadError: (:) [Receive-MSMQueue], InvalidOperationException
      + FullyQualifiedErrorId : ReceiveFailed,Pscx.Commands.Messaging.ReceiveMSMQueue