How can I retrieve the names of all of the private MSMQ queues on the local machine, without using System.Messaging.MessageQueue.GetPrivateQueuesByMachine(".")
? I'm using PowerShell so any solution using COM, WMI, or .NET is acceptable, although the latter is preferable.
Note that this StackOverflow question has a solution that returns all of the queue objects. I don't want the objects (it's too slow and a little flakey when there are lots of queues), I just want their names.
With Windows Server 2012 R2 you have the Message Queueing (MSMQ) Cmdlets installed, use the Cmdlet Get-MsmqQueue to get name and count.
Without Message Queueing (MSMQ) you can use Get-WmiObject
Or over powershell remoting:
or
There is a generic cmdlet command available in powershell Get-MsmqQueue, to accomplish the task in powershell:
Get-MsmqQueue –QueueType Private | select QueueName
This will return names of the private queues in string array. Please be aware the type returned by get-msmqqueue cmdlet is Microsoft.Msmq.PowerShell.Commands.MessageQueue, not System.Messaging.MessageQueue, and seems these two types cannot be converted to each other.
In Powershell everything is an object. You can choose to list certain properties by using the select command which effectively discards the objects.