Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,33 +1,31 @@
---
description: Explains how to create a customize how PowerShell reads input at the console prompt.
description: Explains how to customize how PowerShell reads input at the console prompt.
Locale: en-US
ms.date: 01/04/2018
ms.date: 01/09/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psconsolehostreadline?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about_PSConsoleHostReadLine
---

# about_PSConsoleHostReadLine

## Short description

Explains how to create a customize how PowerShell reads input at the console
prompt.
Explains how to customize how PowerShell reads input at the console prompt.

## Long description

Starting in Windows PowerShell V3, you can write a function named
PSConsoleHostReadLine that overrides the default way that console input is
Starting in Windows PowerShell 3.0, you can write a function named
`PSConsoleHostReadLine` that overrides the default way that console input is
processed.

### EXAMPLES
This function is extended by the **PSReadLine** module.

The following example launches Notepad and gets input from a text File that
### Examples

The following example launches Notepad and gets input from a text file that
the user creates:

```powershell
function PSConsoleHostReadLine
{
function PSConsoleHostReadLine {
$inputFile = Join-Path $env:TEMP PSConsoleHostReadLine
Set-Content $inputFile "PS > "

Expand All @@ -39,18 +37,21 @@ function PSConsoleHostReadLine
}
```

### REMARKS

By default, PowerShell reads input from the console in what is known as
"Cooked Mode" -- in which the Windows console subsystem handles all the
keypresses, F7 menus, and other input. When you press Enter or Tab, Windows
PowerShell gets the text that you have typed up to that point. There is no way
for it to know that you pressed Ctrl-R, Ctrl-A, Ctrl-E, or any other keys
before pressing Enter or Tab. In Windows PowerShell version 3, the
PSConsoleHostReadLine function solves this issue. When you define a function
named PSConsoleHostReadline in the Windows PowerShell console host, Windows
### Remarks

By default, PowerShell reads input from the console in what is known as "Cooked
Mode" -- in which the Windows console subsystem handles all the keypresses,
<kbd>F7</kbd> menus, and other input. When you press <kbd>Enter</kbd> or
<kbd>Tab</kbd>, PowerShell gets the text that you have typed up to that point.
There is no way for it to know that you pressed <kbd>Ctrl</kbd>+<kbd>R</kbd>,
<kbd>Ctrl</kbd>+<kbd>A</kbd>, <kbd>Ctrl</kbd>+<kbd>E</kbd>, or any other keys
before pressing <kbd>Enter</kbd> or <kbd>Tab</kbd>. In Windows PowerShell 3.0,
the `PSConsoleHostReadLine` function solves this issue. When you define a
function named `PSConsoleHostReadline` in the PowerShell console host,
PowerShell calls that function instead of the "Cooked Mode" input mechanism.

## See Also

- [about_Prompts](about_Prompts.md)
- [PSConsoleHostReadLine](/powershell/module/psreadline/psconsolehostreadline)
- [High-Level Console Modes](/windows/console/high-level-console-modes)
2 changes: 1 addition & 1 deletion reference/5.1/PSReadLine/PSConsoleHostReadLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: PSReadLine-help.xml
Locale: en-US
Module Name: PSReadLine
ms.date: 06/27/2024
ms.date: 01/09/2025
online version: https://learn.microsoft.com/powershell/module/psreadline/psconsolehostreadline?view=powershell-5.1&WT.mc_id=ps-gethelp
schema: 2.0.0
title: PSConsoleHostReadLine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
---
description: Explains how to create a customize how PowerShell reads input at the console prompt.
description: Explains how to customize how PowerShell reads input at the console prompt.
Locale: en-US
ms.date: 01/04/2018
ms.date: 01/09/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psconsolehostreadline?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about_PSConsoleHostReadLine
---
# about_PSConsoleHostReadLine

## Short description
Explains how to create a customize how PowerShell reads input at the console
prompt.
Explains how to customize how PowerShell reads input at the console prompt.

## Long description

Starting in Windows PowerShell 3.0, you can write a function named
PSConsoleHostReadLine that overrides the default way that console input is
`PSConsoleHostReadLine` that overrides the default way that console input is
processed.

### EXAMPLES
This function is extended by the **PSReadLine** module.

The following example launches Notepad and gets input from a text File that
### Examples

The following example launches Notepad and gets input from a text file that
the user creates:

```powershell
function PSConsoleHostReadLine
{
function PSConsoleHostReadLine {
$inputFile = Join-Path $env:TEMP PSConsoleHostReadLine
Set-Content $inputFile "PS > "

Expand All @@ -37,18 +37,21 @@ function PSConsoleHostReadLine
}
```

### REMARKS
### Remarks

By default, PowerShell reads input from the console in what is known as "Cooked
Mode" -- in which the Windows console subsystem handles all the keypresses, F7
menus, and other input. When you press Enter or Tab, PowerShell gets the text
that you have typed up to that point. There is no way for it to know that you
pressed Ctrl-R, Ctrl-A, Ctrl-E, or any other keys before pressing Enter or Tab.
In Windows PowerShell 3.0, the PSConsoleHostReadLine function solves this
issue. When you define a function named PSConsoleHostReadline in the PowerShell
console host, PowerShell calls that function instead of the "Cooked Mode" input
mechanism.
Mode" -- in which the Windows console subsystem handles all the keypresses,
<kbd>F7</kbd> menus, and other input. When you press <kbd>Enter</kbd> or
<kbd>Tab</kbd>, PowerShell gets the text that you have typed up to that point.
There is no way for it to know that you pressed <kbd>Ctrl</kbd>+<kbd>R</kbd>,
<kbd>Ctrl</kbd>+<kbd>A</kbd>, <kbd>Ctrl</kbd>+<kbd>E</kbd>, or any other keys
before pressing <kbd>Enter</kbd> or <kbd>Tab</kbd>. In Windows PowerShell 3.0,
the `PSConsoleHostReadLine` function solves this issue. When you define a
function named `PSConsoleHostReadline` in the PowerShell console host,
PowerShell calls that function instead of the "Cooked Mode" input mechanism.

## See Also

- [about_Prompts](about_Prompts.md)
- [PSConsoleHostReadLine](/powershell/module/psreadline/psconsolehostreadline)
- [High-Level Console Modes](/windows/console/high-level-console-modes)
2 changes: 1 addition & 1 deletion reference/7.4/PSReadLine/PSConsoleHostReadLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: PSReadLine-help.xml
Locale: en-US
Module Name: PSReadLine
ms.date: 06/27/2024
ms.date: 01/09/2025
online version: https://learn.microsoft.com/powershell/module/psreadline/psconsolehostreadline?view=powershell-7.4&WT.mc_id=ps-gethelp
schema: 2.0.0
title: PSConsoleHostReadLine
Expand Down
Original file line number Diff line number Diff line change
@@ -1,32 +1,31 @@
---
description: Explains how to create a customize how PowerShell reads input at the console prompt.
description: Explains how to customize how PowerShell reads input at the console prompt.
Locale: en-US
ms.date: 01/04/2018
ms.date: 01/09/2025
online version: https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_psconsolehostreadline?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: about_PSConsoleHostReadLine
---
# about_PSConsoleHostReadLine

## Short description

Explains how to create a customize how PowerShell reads input at the console
prompt.
Explains how to customize how PowerShell reads input at the console prompt.

## Long description

Starting in Windows PowerShell 3.0, you can write a function named
PSConsoleHostReadLine that overrides the default way that console input is
`PSConsoleHostReadLine` that overrides the default way that console input is
processed.

### EXAMPLES
This function is extended by the **PSReadLine** module.

### Examples

The following example launches Notepad and gets input from a text File that
The following example launches Notepad and gets input from a text file that
the user creates:

```powershell
function PSConsoleHostReadLine
{
function PSConsoleHostReadLine {
$inputFile = Join-Path $env:TEMP PSConsoleHostReadLine
Set-Content $inputFile "PS > "

Expand All @@ -38,18 +37,21 @@ function PSConsoleHostReadLine
}
```

### REMARKS
### Remarks

By default, PowerShell reads input from the console in what is known as "Cooked
Mode" -- in which the Windows console subsystem handles all the keypresses, F7
menus, and other input. When you press Enter or Tab, PowerShell gets the text
that you have typed up to that point. There is no way for it to know that you
pressed Ctrl-R, Ctrl-A, Ctrl-E, or any other keys before pressing Enter or Tab.
In Windows PowerShell 3.0, the PSConsoleHostReadLine function solves this
issue. When you define a function named PSConsoleHostReadline in the PowerShell
console host, PowerShell calls that function instead of the "Cooked Mode" input
mechanism.
Mode" -- in which the Windows console subsystem handles all the keypresses,
<kbd>F7</kbd> menus, and other input. When you press <kbd>Enter</kbd> or
<kbd>Tab</kbd>, PowerShell gets the text that you have typed up to that point.
There is no way for it to know that you pressed <kbd>Ctrl</kbd>+<kbd>R</kbd>,
<kbd>Ctrl</kbd>+<kbd>A</kbd>, <kbd>Ctrl</kbd>+<kbd>E</kbd>, or any other keys
before pressing <kbd>Enter</kbd> or <kbd>Tab</kbd>. In Windows PowerShell 3.0,
the `PSConsoleHostReadLine` function solves this issue. When you define a
function named `PSConsoleHostReadline` in the PowerShell console host,
PowerShell calls that function instead of the "Cooked Mode" input mechanism.

## See Also

- [about_Prompts](about_Prompts.md)
- [PSConsoleHostReadLine](/powershell/module/psreadline/psconsolehostreadline)
- [High-Level Console Modes](/windows/console/high-level-console-modes)
2 changes: 1 addition & 1 deletion reference/7.5/PSReadLine/PSConsoleHostReadLine.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
external help file: PSReadLine-help.xml
Locale: en-US
Module Name: PSReadLine
ms.date: 06/27/2024
ms.date: 01/09/2025
online version: https://learn.microsoft.com/powershell/module/psreadline/psconsolehostreadline?view=powershell-7.5&WT.mc_id=ps-gethelp
schema: 2.0.0
title: PSConsoleHostReadLine
Expand Down