Powershell 术语 'Get-MsmqQueue' 未被识别为 Windows Server 2008 R2 SP1 中的 cmdlet 的名称

Powershell The term 'Get-MsmqQueue' is not recognized as the name of a cmdlet in Windows Server 2008 R2 SP1

我正在尝试在 Windows Server 2008 R2 SP1 (x64) 中使用命令 Get-MsmqQueue,但出现以下错误:

Get-MsmqQueue : The term 'Get-MsmqQueue' is not recognized as the name of a
cmdlet, function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1
+ Get-MsmqQueue
+ ~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Get-MsmqQueue:String) [], Comma
   ndNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

机器上安装了 MSMQ,Powershell 版本是 5,我已经重新安装了 MSMQ,什么也没有。

我该如何解决这个问题?

虽然您已经安装了 PowerShell 版本 5,但它不会包含任何新的 cmdlet。原因是这些 cmdlet 与 OS 可用的 API 相关联,而 2008 R2 没有所需的 API。您将无法使用该 cmdlet,因为它最初是在服务器 2012 中可用的。

您可以通过使用 WMI 提取 MSMQ 数据来解决此问题,但我不知道具体操作方法。这个答案 here 显示了一个例子。