I have installed the MSMQ feature onto both server (win 2008 R2) and client machine (win 7) using the following Link. The Feature appears in the server manager and I am able
The below method works in Powershell 2.0:
$query = "SELECT MessagesinQueue FROM Win32_PerfRawData_MSMQ_MSMQQueue WHERE Name = 'myPrivateQueueName'"
$wmiObject = Get-WmiObject -Query $query
$wmiObject.MessagesinQueue
You can list the queues with this query:
$query = "SELECT * FROM Win32_PerfRawData_MSMQ_MSMQQueue"
Look at the __PATH property which will end in .Name="theQueueName"