Windows PowerShell Home
Receive-MsmqQueue -Peek throws a terminating error if queue is empty
Keith Hill MVP
12/30/2012 2:24:10 PM
User(s) can reproduce this bug
When testing if a queue has a message or is empty, I don't expect the "Peek" method to throw a terminating error to indicate the queue is empty. It would be much nicer to return either the first message or $null if the queue is empty. At the very least, write a non-terminating error instead of throwing a terminating error so I still get back a $null from the operation.
How often does this happen?
Have you seen this problem before in this product?
I don't know if this issue existed previously
$queueName = 'JobMessages'
$q = New-MsmqQueue $queueName
$msgAvailable = Receive-MsmqQueue -InputObject $q -Peek
I expect Receive-MsmqQueue to return a $null if the queue is empty and perhaps write a non-terminating error indicating this to be the case.
to post a comment.
Please enter a comment.
to post a workaround.
Please enter a workaround.
© 2013 Microsoft