How to retrieve names of all private MSMQ queues - efficiently? How to retrieve names of all private MSMQ queues - efficiently? powershell powershell

How to retrieve names of all private MSMQ queues - efficiently?


$obj = Get-WmiObject Win32_PerfRawdata_MSMQ_MSMQQueue ##will return an Object[] array$obj[0].name ## will return the 1st Queue Name

Also, you can do this to find out more methods / properties on this object -

$obj | Get-Member

To List only private Qs, you may use this -

Get-WmiObject Win32_PerfRawdata_MSMQ_MSMQQueue |    ?{$_.Name -match "private"} |        %{$_.Name} 


Starting with Windows Server 2012 and Win8, PS has a Get-MsmqQueue command. It is faster than the get-wmiobject method in my tests.

Measure-Command {  $list = Get-MsmqQueue -QueueType Private | % {$_.QueueName}}Measure-Command {  $list = Get-WmiObject Win32_PerfRawdata_MSMQ_MSMQQueue | ?{$_.Name -match "private"} | %{$_.Name} }