[英]Parameter issue with plink and PowerShell
我正在尝试使用plink切换到交换机,但是我的参数始终出现错误。
$plink = 'C:\Program Files (x86)\PuTTY\plink.exe'
$switch = "172.20.19.50"
$commands = "c:\scripts\cmd.txt"
$username = Read-Host "User name"
$pw = Read-Host -Prompt "Enter password" -AsSecureString
$plink -l $username -pw $pw -m $commands -ssh $switch
这些是我得到的错误:
You must provide a value expression on the right-hand side of the '-' operator.
At line:7 char:8
Unexpected token 'l' in expression or statement.
At line:7 char:9
Unexpected token 'username' in expression or statement.
At line:7 char:11
Unexpected token '-pw' in expression or statement.
At line:7 char:21
Unexpected token 'pw' in expression or statement.
At line:7 char:25
Unexpected token '-m' in expression or statement.
At line:7 char:29
Unexpected token 'commands' in expression or statement.
At line:7 char:32
Unexpected token '-ssh' in expression or statement.
At line:7 char:42
Unexpected token 'switch' in expression or statement.
At line:7 char:47
据我所知,我的参数是正确的,知道为什么它不起作用吗?
您需要告诉powershell您正在运行带有参数的命令,否则它不知道如何解释参数列表,要使其正常工作,您只需在命令前添加&
符号即可:
& $plink -l $username -pw $pw -m $commands -ssh $switch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.