11---
2- description : Explains how to create a customize how PowerShell reads input at the console prompt.
2+ description : Explains how to customize how PowerShell reads input at the console prompt.
33Locale : en-US
4- ms.date : 01/04/2018
4+ ms.date : 01/09/2025
55online version : https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psconsolehostreadline?view=powershell-5.1&WT.mc_id=ps-gethelp
66schema : 2.0.0
77title : about_PSConsoleHostReadLine
88---
9-
109# about_PSConsoleHostReadLine
1110
1211## Short description
13-
14- Explains how to create a customize how PowerShell reads input at the console
15- prompt.
12+ Explains how to customize how PowerShell reads input at the console prompt.
1613
1714## Long description
1815
19- Starting in Windows PowerShell V3 , you can write a function named
20- PSConsoleHostReadLine that overrides the default way that console input is
16+ Starting in Windows PowerShell 3.0 , you can write a function named
17+ ` PSConsoleHostReadLine ` that overrides the default way that console input is
2118processed.
2219
23- ### EXAMPLES
20+ This function is extended by the ** PSReadLine ** module.
2421
25- The following example launches Notepad and gets input from a text File that
22+ ### Examples
23+
24+ The following example launches Notepad and gets input from a text file that
2625the user creates:
2726
2827``` powershell
29- function PSConsoleHostReadLine
30- {
28+ function PSConsoleHostReadLine {
3129 $inputFile = Join-Path $env:TEMP PSConsoleHostReadLine
3230 Set-Content $inputFile "PS > "
3331
@@ -39,18 +37,21 @@ function PSConsoleHostReadLine
3937}
4038```
4139
42- ### REMARKS
43-
44- By default, PowerShell reads input from the console in what is known as
45- "Cooked Mode" -- in which the Windows console subsystem handles all the
46- keypresses, F7 menus, and other input. When you press Enter or Tab, Windows
47- PowerShell gets the text that you have typed up to that point. There is no way
48- for it to know that you pressed Ctrl-R, Ctrl-A, Ctrl-E, or any other keys
49- before pressing Enter or Tab. In Windows PowerShell version 3, the
50- PSConsoleHostReadLine function solves this issue. When you define a function
51- named PSConsoleHostReadline in the Windows PowerShell console host, Windows
40+ ### Remarks
41+
42+ By default, PowerShell reads input from the console in what is known as "Cooked
43+ Mode" -- in which the Windows console subsystem handles all the keypresses,
44+ <kbd >F7</kbd > menus, and other input. When you press <kbd >Enter</kbd > or
45+ <kbd >Tab</kbd >, PowerShell gets the text that you have typed up to that point.
46+ There is no way for it to know that you pressed <kbd >Ctrl</kbd >+<kbd >R</kbd >,
47+ <kbd >Ctrl</kbd >+<kbd >A</kbd >, <kbd >Ctrl</kbd >+<kbd >E</kbd >, or any other keys
48+ before pressing <kbd >Enter</kbd > or <kbd >Tab</kbd >. In Windows PowerShell 3.0,
49+ the ` PSConsoleHostReadLine ` function solves this issue. When you define a
50+ function named ` PSConsoleHostReadline ` in the PowerShell console host,
5251PowerShell calls that function instead of the "Cooked Mode" input mechanism.
5352
5453## See Also
5554
5655- [ about_Prompts] ( about_Prompts.md )
56+ - [ PSConsoleHostReadLine] ( /powershell/module/psreadline/psconsolehostreadline )
57+ - [ High-Level Console Modes] ( /windows/console/high-level-console-modes )
0 commit comments