In Windows Powershell (admin):
Connect to Remote Windows
$session = New-PSSession -ComputerName "xx.xx.xx.xx"
Attempting Remote Execution
Invoke-Command -Session $session -ScriptBlock {
cd C:\Path
ls
Start-Process -FilePath "C:\Path\MyProgram.exe"
start-Process cmd
}
The cd and ls commands work as expected, but the Start-Process cmd and MyProgram.exe do not launch. No windows appear; it seems to be skipped.
I've also tried another approach:
PS C:\Jenkins> Enter-PSSession -Session $session
[xx.xx.xx.xx]: PS C:\Users\Administrator\Documents> Start-Process cmd
[xx.xx.xx.xx]: PS C:\Users\Administrator\Documents> (nothing happens)
Both way failed to launch or execute a new window or .exe file.
I tried to execute commands remotely and expected new windows or applications to be launched, but this did not happen.
-NoNewWindow, what happens?-Wait -NoNewWindowis a poor substitute for direct invocation locally, in remote invocations the-NoNewWindowcauses the child process' output not to be shown - direct invocation works in principle in remote session (synchronously, in the same window, with standard streams connected to PowerShell's streams), but running interactive console applications (e.g.cmd.exewithout/C) is fundamentally unsupported.