PowerShell functions cannot return System.Messaging.MessageQueue objects - by Neil Barnwell

Status : 


Sign in
to vote
ID 783463 Comments
Status Active Workarounds
Type Bug Repros 0
Opened 4/11/2013 9:15:14 AM
Access Restriction Public


Any given PowerShell function that successfully creates an instance of System.Messaging.MessageQueue is not able to return that object, by any means.
Sign in to post a comment.
Posted by Bartek Bielawski on 5/31/2013 at 1:41 PM
Not sure if that would work here - you may want to use unary comma to return IEnumerables:
function foo {
, $out
Posted by Neil Barnwell on 4/11/2013 at 3:49 PM
I'm an idiot. It's not a bug, but it's interesting. Because `System.Messaging.MessageQueue` implements `System.Collections.IEnumerable` by enumerating it's messages, the behaviour I was seeing was that PowerShell was actually reading the messages off the newly-created queues and putting them into the pipeline rather than the queue objects themselves. Of course because the queues were new, they were empty, so there was nothing passed on down the pipeline.

I just spent most of this afternoon and some hours this evening working this out. I am not proud of myself.