Home Forums Programming Powershell How to pass a response to a .exe called by PoSh RE: How to pass a response to a .exe called by PoSh

  • Hmmmmm.

    I found this on the net; the author plainly states it's a bit of a hack, but also claims to have made it work for him. I've not been able to get this to work myself.

    #Pass the Y and exit

    $PlinkCommand = [string]::Format('echo y | & "{0}" {1} exit',

    $PlinkAndPath, $plinkoptions )

    Write-Host $PlinkCommand

    $msg = Invoke-Expression $PlinkCommand

    Where

    $PlinkAndPath is path to .exe, and

    $plinkoptions are the parameters (username, password, hostname, etc)