Powershell Press Any Key To Continue

This cmdlet is part of the Vexasoft Cmdlet Library. You can download it now or click here to find out more.
  1. Powershell Press Enter To Exit
  2. Powershell Press Enter To Continue
  3. Powershell Press Any Key To Continue Ise

It is important to note that this method is only available in the PowerShell console this does not work in the PowerShell Integrated Scripting Environment (ISE). A simple example: You might require your script to ask for Yes / No, using the Read-Host would allow the user to type in more than one character and the enter key would have to be pressed. This returns the key code of the key pressed which is the row number followed by the column number. The left up and down arrow keys are grouped with row 2 as 24, 25, and 26, and the down arrow key is grouped with row 3 as 34. This returns the key code of the key pressed. Let keycode=0 print 1 'Press any key and its key code will. 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. Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, pass in the string «A» to the method.

Synopsis

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.

Powershell Press Enter To Exit

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

Wait-KeyPress does not accept input objects.

Outputs

Wait-KeyPress does not output any Powershell objects. Input

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

This command will will pause the current Powershell session without displaying a message to the user:

Powershell Press Enter To Continue

C:PS>Wait-KeyPress -Quiet

Introducction

Powershell Press Any Key To Continue Ise

Each key is represented by one or more characters. To specify a single keyboard character, use the character itself. For example, to represent the letter A, pass in the string «A» to the method. To represent more than one character, append each additional character to the one preceding it. To represent the letters A, B, and C, specify the parameter as «ABC».

The plus sign (+), caret (^), percent sign (%), tilde (~), and parentheses () have special meanings to SendKeys. To specify one of these characters, enclose it within braces ({}). For example, to specify the plus sign, use «{+}». To specify brace characters, use «{{}» and «{}}». Brackets ([ ]) have no special meaning to SendKeys, but you must enclose them in braces. In other applications, brackets do have a special meaning that might be significant when dynamic data exchange (DDE) occurs.

To specify characters that aren’t displayed when you press a key, such as ENTER or TAB, and keys that represent actions rather than characters, use the codes in the following table.

To specify keys combined with any combination of the SHIFT, CTRL, and ALT keys, precede the key code with one or more of the following codes.

Examples