I've just had two occurrences of windows 7 stalling an execution until I hit enter on the command prompt/powershell. Afterward execution seems to continue as expected. First was an batch file of copy commands like. Copy //host/file2010-1.xml localfolder/01/ copy //host/file 2010-2.xml localfolder/02/ One file seemed to be taking ages. I've recently created a fork of the WSMan client that PowerShell uses for PSRemoting on non-Windows hosts. For anyone who's tried to use PSRemoting on Linux to target Windows hosts, or even Exchange Online, would probably know the pain of getting it working at all. The ReadKey method waits, that is, blocks on the thread issuing the ReadKey method, until a character or function key is pressed. A character or function key can be pressed in combination with one or more Alt, Ctrl, or Shift modifier keys. However, pressing a modifier key by itself will not cause the ReadKey method to return.
Press any key to continue. This thread is archived. New comments cannot be posted and votes cannot be. How do you do a ‘Pause’ with PowerShell 2.0? (5 answers) Closed 4 years ago. According to Microsoft's documentation, read-host lets the user type some input, and then press enter to continue. Not exactly the correct behavior if you want to have 'Press any key to continue'.
Synopsis
Powershell Press Any Key To Continue
Waits (pauses the session) until a user presses a key. For use in scripts.Syntax
- Wait-KeyPress [-Message] [-Quiet]
Description
The Wait-KeyPress cmdlet pauses the Powershell session until the user presses a key.Parameters
- Message The message to display to the user. By default the message is 'Press any key to continue...'
- Quiet Do not display a message.
Inputs
Powershell Sendkeys Example
Wait-KeyPress does not accept input objects.Outputs
Wait-KeyPress does not output any Powershell objects.Notes
The are no notes associated with the Wait-KeyPress cmdlet.Example 1
This command will pause the current Powershell session with the message 'Press any key to continue...':C:PS>Wait-KeyPress
Example 2
This command will pause the current Powershell session with the message 'Hit a button to proceed...':C:PS>Wait-KeyPress -Message 'Hit a button to proceed...'
Example 3
Powershell Press Any Key To Continue Ise
This command will will pause the current Powershell session without displaying a message to the user:Powershell Bypass Press Any Key To Continue
C:PS>Wait-KeyPress -Quiet