Accessing MSMQ via PowerShell

喜欢而已 提交于 2019-12-01 05:52:07

If you click up one level in the link you provided you'll see that you're looking at pre-release PowerShell 4.0 module documentation. Here's the link to the parent page.

http://technet.microsoft.com/en-us/library/dn249523.aspx

PowerShell Community Extensions (PSCX) has some cmdlets for working with MSMQ, and it works with PowerShell 2.0, though.

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"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!