Execution of interactive command in remote Powershell session not working Execution of interactive command in remote Powershell session not working powershell powershell

Execution of interactive command in remote Powershell session not working


Interactive native windows console commands are not supported in a remote powershell session. I know this sounds dumb, but currently this is the case (as of PowerShell v4.0).

Most command line utilities support some form of automation, be it piping or passing values as arguments so take a closer look at the tools you're using. Of course this is on a case by case basis. There is no easy way to intercept an interactive prompt on the remote end in any universal manner.


You can sidestep the issue by using Invoke-command cmdlet which executes and exits

Invoke-Command -ComputerName Mobius -ScriptBlock {## your stuff}

and combine it with pipe so in the case of the date command

Invoke-Command -ComputerName Mobius -ScriptBlock {echo "01-02-1999" |cmd /c date}

or for plink

Invoke-Command -ComputerName Mobius -ScriptBlock {"yourpassword"| &'c:\Program Files (x86)\Putty\plink.exe' merlin -l joe `"bashcommand1 && bashcommand2`" }

or even simpler

Invoke-Command -ComputerName Mobius -ScriptBlock { &'c:\Program Files (x86)\Putty\plink.exe' merlin -l joe -pw yourpass `"bashcommand1 && bashcommand2`" }

but as @X0n said no real interactivity.