powershell - 脚本 PowerShell 以使用 SSH 连接到多个 HP ProCurve 交换机
问题描述
我想使用 SSH 连接到多个 HP 交换机。首先,我需要使用 SSH 连接到服务器。我使用plink
:
putty\plink.exe -ssh user@x.x.x.x -pw psss
我需要一个带有交换机 IP 列表的文件。
当我连接到服务器时,我必须使用plink
连接到 HP 交换机:
putty\plink.exe -ssh user@x.x.x.x -pw psss < .\commands.txt >> .\output.txt 2>>&1
commands.txt
文件包含以下命令:
display device maninfo
你能帮我完成这段代码吗?
解决方案
正如安斯加尔所说
Foreach ($ip in (cat c:\iplist.txt) {
putty\plink.exe -ssh user@$ip -pw psss
}
是你可能想要的。