In developing a script that would read a MSMQ queue message, modify it, and send to another MSMQ queue, I first (in the same development script) created a message into the very queue I was testing reading from. When I got my transformation all together, I removed the command to create the source message and did that in a separate powershell instance, since I was done with interactive test message debugging. I discovered that now.. just receiving the MSMQ message without first using send() in the script, that the returning object(s) now only contains the message in BodyStream and no longer in Body. How can I instruct the .receive() to populate the return object's "Body" attribute?
Doing even this: [System.Reflection.Assembly::LoadWithPartialName("System.Messaging") | Out-Null
$SourceQueue = new-object system.message.messagequeue ".\private$\SourceQueue" $SourceQueue.Send("Garbage")
I stop here and purge the SourceQueue... then externally populate a message into the queue. Then if I go this:
$QueueMessage = $SourceQueue.Receive()
The Object has the message within the "Body" attribute
... But ... If I don't Send() first and run like this:
[System.Reflection.Assembly::LoadWithPartialName("System.Messaging") | Out-Null
$SourceQueue = new-object system.message.messagequeue ".\private$\SourceQueue" $QueueMessage = $SourceQueue.Receive()
I do NOT get the message into the Body attribute of the object
Does using the .Send() somehow set a property or load an assembly that then allows the messagebody to populate Body?