【发布时间】:2017-10-06 04:15:10
【问题描述】:
我在 Win 7 中安装了 telnet 客户端。现在我尝试在 PowerShell 中运行它。我需要这样做才能在远程主机中运行命令ewfmgr d: -commit。我用
Invoke-Command -ComputerName [MyComp] -scriptblock {cmd.exe /c "telnet"}
但什么也没发生。是否可以使用 CMD 运行 telnet 并传输参数(IP、用户名、密码、命令)?
我也试过了
Invoke-Command -Command {cmd.exe /c C:\Windows\System32\telnet.exe}
& "C:\Windows\System32\telnet.exe"
Invoke-Command -ScriptBlock {C:\Windows\System32\telnet.exe}
我尝试做同样的事情here。
【问题讨论】:
-
什么都没有发生,因为 Telnet 客户端是交互式程序。它等待用户输入。编写 Telnet 脚本很痛苦,您可以使用 SSH 代替吗?
-
如果您必须使用 telnet,至少使用实际上是可编写脚本的 telnet 客户端,例如
plink来自PuTTY suite。
标签: powershell cmd telnet