PowerShell Genie

PSReadLine module: setup and commands

Module 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Configure command history, prediction, completion and key handlers with PSReadLine while checking host support and avoiding shared-history surprises.

Getting it

Bundled with PowerShell 5.1 and later. Move to the current release with Install-PSResource -Name PSReadLine.

Examples

1PS> Get-PSReadLineOption
Show reference output
1 C:\Users\demo\AppData\Roaming\Microsoft\Windows\PowerShell\PSReadLine\ConsoleHost_history.txt
1PS> Get-PSReadLineKeyHandler
Show reference output
1 Key Function Description
2 --- -------- -----------
3 Ctrl+c CopyOrCancelLine Copy selected text or cancel line
4 Ctrl+r ReverseSearchHistory Search command history backward
5 Tab MenuComplete Complete the current token

What it is for

Configure it when interactive work fills a large part of your day, particularly history search and key bindings. It matters for security reviews too, because it writes a plain text history file that can capture whatever was typed at the prompt.

Typical tasks

  • Search history with a partial command
  • Rebind keys to an editing style you prefer
  • Turn on predictive suggestions from history
  • Change how the prompt colors errors
  • Relocate or shorten the history save file
  • Stop sensitive commands from being recorded

Check the installed version

1PS> Get-Module -ListAvailable PSReadLine | Select-Object Name, Version, Path
2PS> Get-Command -Module PSReadLine

Compare the module path and version with the session used by your scheduled task or automation account. Configure it when interactive work fills a large part of your day, particularly history search and key bindings. It matters for security reviews too, because it writes a plain text history file that can capture whatever was typed at the prompt.

Primary documentation

PSReadLine documentation

Continue
Genie guidePSReadLine module: setup and commands

Configure command history, prediction, completion and key handlers with PSReadLine while checking host support and avoiding shared-history surprises.