1) Set the PowerShell Window Title to
something specific:
$host.ui.RawUI.WindowTitle
= "Your Title"
2) Save a script called say
“SendPassword.ps1” with the below content to somewhere accessible (I’ll use 'C:\MY TOOLS' in this post):
$wshell
= New-Object -ComObject wscript.shell;
$wshell.AppActivate('Your
Title)
Sleep 4
$wshell.SendKeys('YourPassword')
$wshell.SendKeys('~')
Note:
You will need to tune the sleep timer so that it finishes after the ‘Password’
prompt appears. 4 seconds worked for me in the example below.
3) Run your SSH command from PowerShell
like below:
start
powershell.exe '.\SendPassword.ps1' -WorkingDirectory 'C:\MY TOOLS'; ssh.exe admin@10.0.0.200
node show local -fields serialnumber
Image:
Screenshot of the setup
Comments
Post a Comment