I saw a solution to cache a server host key by adding the command just below on the top of my script before running the other Plink tasks.
& "echo y | C:\Program Files\PuTTY\plink.exe" -ssh -batch -i $PrivateKeyPath $username "exit" 2>&1
Error message:
The term 'echoy| C:\ProgramFiles\PuTTY\plink.exe' is not recognized as the name of a cmdlet,...
So the spaces prior the pipe symbol are removed and therefore the command is not recognized.
My other attempt is to use Start-Process
but I do not know how I am able to prepend echo y |
to the plink.exe path.
Start-Process -FilePath 'C:\Program Files\PuTTY\plink.exe' -Argumentlist "-ssh -batch -i $PrivateKeyPath $username $command 2>&1"
Is there an option to prepend something to the -FilePath
?