Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Windows PowerShell ISE doesn't promt for input

I am using console as my tool for managing mercurial repositories. Wtih classic cmd or Console2 I type:

hg in

And console prompts something like:

D:\workspace\someproject>hg in
http authorization required
realm: Bitbucket.org HTTP
user: xorty
password:

And obviously, I type password.

But when I type "hg in" in powershell console, it doesn't prompt anything. It just keeps saying this: Running script / selection. Press Ctrl + Break to stop

Can I make PowerShell ISE behave like classic console, or this isn't the way PowerShell is meant to work?

like image 353
Xorty Avatar asked Nov 30 '11 20:11

Xorty


People also ask

How do I get the PowerShell prompt for user input?

The Read-Host cmdlet reads a line of input from the console (stdin). You can use it to prompt a user for input. Because you can save the input as a secure string, you can use this cmdlet to prompt users for secure data, such as passwords.

How do I get the PowerShell prompt?

To get the Prompt function, use the Get-Command cmdlet or use the Get-Item cmdlet in the Function drive. To get the script that sets the value of the prompt, use the dot method to get the ScriptBlock property of the Prompt function.

Why is PowerShell not recognizing commands?

Cause. This is caused by the user (or system) PATH environment variable not containing the directory where the PowerShell executable resides. It's usually located at C:\Windows\System32\WindowsPowerShell\v1.

How do you take input from output in PowerShell?

There are cmdlet for console input and output using PowerShell. In Windows Powershell, the input and output are given through the Host. It uses 'Write-Host' to print and 'Read-Host' to get input from console.


2 Answers

The PowerShell ISE indeed does not support console applications that require interactive input. The linked blog entry details options how to deal with that.

Since the PowerShell ISE is not a console, normal console applications cannot do everything they're used to, while of course PowerShell cmdlets can work just fine, since several things are dependent on the PowerShell host application (you get a graphical prompt with Read-Host, for example).

Console2 emulates a normal console by keeping the actual console around in a hidden window and polling it repeatedly for changes and, correspondingly, sending input to that window.

like image 58
Joey Avatar answered Nov 09 '22 17:11

Joey


Powershell ISE ( integrated scripting environment ) is not the standard Powershell console. The ISE, like the name suggests, is a pretty basic GUI based script writing tool and doesn't support interactive console applications ( try just cmd on the ISE console and see the error message)

Open powershell.exe, and run the command that you want. It will behave pretty much like cmd. Or alternatively, press CTRL+SHIFT+P in the ISE and run the command there.

like image 25
manojlds Avatar answered Nov 09 '22 18:11

manojlds