Execution of interactive command in remote Powershell session not working
powershell, remote-access, windows
Solution
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.
Problem
I am having troubles executing commands in a remote PowerShell session which need user interaction. Example: I enter a remote session ``` Enter-PSSession -ComputerName mobius ``` In this session I execute a command which asks for a password: ``` [mobius]: PS C:\Windows\system32> & 'c:\Program Files (x86)\Putty\plink.exe' merlin -l joe joe@merlin's password: c:\Program Files (x86)\Putty\plink.exe : Using username "plakat". + CategoryInfo : NotSpecified: (Using username "plakat".:String) [], RemoteException + FullyQualifiedErrorId : NativeCommandError ``` The last two lines are displayed in red. There seem to be two problems. Problem 1: plink.exe writes the text 'Using username "plakat"' to stderr. This probably causes the error message. Can I suppress this somehow? (pipe stderr to stdout or something.) Problem 2: The process exits at the point where I should enter the password. I can also reproduce that with other commands like ``` [mobius]: PS C:\Windows\system32> cmd /c date ``` It does not let me enter a date. Both commands work if I run them in a local PowerShell. Neither Problem 1 or 2 are showing in that case.