从 power-shell 命令/脚本进行远程 IBM MQ 监控

remote IBM MQ monitoring from power-shell commands / scripts

我正在尝试使用 PowerShell script/commands 获取远程 IBM MQ 的队列深度。好像不能正常工作,请帮助。

{
$myremoteconns = New-WMQQmgrConnDef -Name T.test.TEST.QM1 -Hostname abcd_testhost01 -Port 1111 -Channel T.test.MQMQ.TESTCHN

$qm = Get-WMQQueueManager -Connections $myremoteconns | where {$_.Name -like 'T.test.TEST.QM1'} 

Error New-WMQQmgrConnDef the term 'New-WMQQmgrConnDef' is not recognized

已经安装了 WebSphere MQ - Windows 下面的 PowerShell 库。

http://www-01.ibm.com/support/docview.wss?uid=swg24017698

谢谢

这个错误意味着 PowerShell 找不到这个 cmdlet。您需要检查您安装的模块是否被 PowerShell 正确找到。先检查一下:

Get-Module -ListAvailable

结果会是这样的:

PS C:\Users\username\PowerShell> get-module -ListAvailable


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     3.0.1      ImportExcel                         {Import-Html, ConvertFrom-ExcelSheet, PieChart, Import-UPS...}

如果您没有在列表中找到该模块,您可以使用以下方法手动导入它:

Import-Module -Name 'C:\path\to\module.psm1'

在 PowerShell(从 V3 开始)中,如果模块位于环境变量 PSModulePath 中指定的路径中,则它们应该被自动导入。您可以使用以下命令检查其值:

$env:PSModulePath

一旦您知道此变量中包含哪些文件夹,您就可以将模块移到那里,或者使用

添加另一个路径
$env:PSModulePath = $env:PSModulePath + ";c:\path\to\module"

这将适用于当前会话。如果你想为所有会话修改它,你可以将下面的行添加到 PowerShell 配置文件。

更多信息: