Reputation: 19
I am trying to ssh into a switch using plink, but I keep getting errors with my parameters.
$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
These are the errors I am getting:
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
My parameters are correct as far as I can see, any idea why it isn't working?
Upvotes: 1
Views: 1154
Reputation: 9278
You need to tell powershell that you're running a command with parameters, otherwise it doesn't know how to interpret your list of arguments, to get this working, you can simply add the &
symbol before your command:
& $plink -l $username -pw $pw -m $commands -ssh $switch
Upvotes: 1