Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hang / crash when powershell is executed from cmd via ssh (Windows 10 Pro) #166

Closed
mesmariusz opened this issue Mar 25, 2016 · 6 comments
Closed

Comments

@mesmariusz
Copy link

Dears

I have on my remote Win 10 SSH installed follow instruction below:

https://github.com/PowerShell/Win32-OpenSSH/wiki/Install-Win32-OpenSSH

Connection to cmd works perfectly but after powershell is executed (from cmd) then connection looks like below (no commands can be executed - looks like no response from remote cmd).

http://filmy.elektroda.net/58_1458919094.mp4

Is this a bug? Please give me some hints / or please support me somehow.

Thank you and best regards.
Mariusz

@nachfuellbar
Copy link

#159

like @manojampalam said in this issue, you can expect a better working solution end of May

@manojampalam
Copy link
Contributor

Try the following:
Powershell -File -

That's telling Powershell to redirect its IO streams through std IO.

@manojampalam
Copy link
Contributor

@mesmariusz
Copy link
Author

Thank you. Now it works: http://filmy.elektroda.net/48_1458924598.mp4

Only one question mark: why 'new line' (enter) works so oddly ?

@manojampalam
Copy link
Contributor

the 'new line' should work better with the latest version. I put in a work around for now.

@C-Duv
Copy link

C-Duv commented May 11, 2016

I had issues when execution PowerShell scripts from a .bat script that I started via a SSH session.
I've stepped onto this GH issue but in my case I wanted to run PowerShell scripts, not PowerShell interactive console.

Steps:

  1. I open an SSH session to a Windows 7 workstation
  2. I type the following command: C:\foobar\install.bat
  3. install.bat script hangs in the middle of it's execution

Files

install.bat:

@echo off
echo Starting
cmd.exe /C powershell.exe -File "file1.ps1"
echo Done with file1
cmd.exe /C powershell.exe -File "file2.ps1"
echo Done with file2

file1.ps1:

Write-Host "EOF file1"

file2.ps1:

Write-Host "EOF file2"

Script would only print:

install.bat
           Starting
EOF file1
         _

And hangs. I had to press [Enter] for the file2.ps1 to run:

install.bat
           Starting
EOF file1

Done with file1
EOF file2
         _

And once more for the install.bat to end:

install.bat
           Starting
EOF file1

Done with file1
EOF file2

Done with file2

In my real use case, the stuff the file1.ps1 was doing (calling external binaries) made the "[Enter]-trick" not working (I had to kill the Powershell process).

My solution:

Use the -InputFormat None powershell.exe's option:

install.bat:

@echo off
echo Starting
cmd.exe /C powershell.exe -InputFormat None -File "file1.ps1"
echo Done with file1
cmd.exe /C powershell.exe -InputFormat None -File "file2.ps1"
echo Done with file2

Outputs:

install.bat
           Starting
EOF file1
         Done with file1
EOF file2
         Done with file2

Let's hope this help someone.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants