Enhance PowerShell with the PSReadLine Module

A graphic image of PowerShell inscription on the background of a computer.
Enhance PowerShell with the PSReadLine module!

PowerShell is one of Windows operating system’s best features enabling you to do many incredible things! That said, the PowerShell interface isn’t easy to navigate. While you can use a third-party editor instead of the default PowerShell interface, you can still improve the existing interface. One of the tools to enhance PowerShell is the PSReadLine module. The tool adds features like syntax highlighting, command history tracking, etc. 

Learn how the PSReadLine module works in this article.

How to Enable the PSReadLine Module

The PSReadLine module has been around for a long time. Early in its history, the module’s users had to download it from GitHub or from the PowerShell Gallery. That said, you can now easily download the module without ever leaving PowerShell. You won’t even have to manually initiate the download process. Just open an elevated PowerShell session and enter the following command:

Install-Module PSReadLine

If the module exists on your computer, this command will load it into memory. Otherwise, this command will prompt you to download the module as shown in the figure below:

A screenshot of the Administrators Windows PowerShell showing the prompt responding to the install command.
PowerShell automatically attempts to download the PSReadLine module if you don’t already have it.

Now, let’s take a look at some of the module’s features.

Top Module Features

As I’ve mentioned, the PSReadLine module is a great tool to enhance your PowerShell interface. Let’s discuss 2 of its best features

1. Syntax Highlighting

One of the main features included with the module is syntax highlighting. At first, this might not seem like a big deal since PowerShell has natively included syntax highlighting for years. That said, what makes the PSReadLine different is that it gives you the ability to choose your own colors.

One element many people like modifying is PowerShell’s inline predictions. Users could manually enable inline predictions before Microsoft removed this requirement in their most recent version.

Unfortunately, changing the inline prediction color isn’t quite as straightforward as you might expect. To do so, you’ll have to specify an emphasis color and the inline prediction color. The emphasis color is the color used when you press the up arrow to repeat a previous command. This color must be entered as a hexadecimal value. The inline prediction color can be entered as a color name. For example, if you want to set the emphasis color to red and the inline prediction color to blue, you’d use this command:

Set-PSReadLineOption -Colors @{emphesis=’#FF0000′; InLinePrediction=’Blue’}

2. Command History

Another helpful feature is the ability to track command use and compile a command history. While having a historical record of commands used can be helpful for forensic purposes, the inline predictions feature also uses the history to predict other commands.

If you want to see your command history, just type Get-History. Interestingly, you can also use another command called Invoke-History to rerun commands you’ve used in the past. Entering Invoke-History on its own causes the execution of your most recently-used command. That said, you can also execute older commands.

The Get-History command displays a number next to each command. When you use the Invoke-History command, you can include the ID parameter and the number associated with the command that you want to run. For example, if you want to run command number 5, you’d type:

Invoke-History -ID 5

A screenshot of the Invoke-History command to use.
You can use the Invoke-History command to repeat a previously used command.

The Bottom Line

The PSReadLine module offers a vast improvement to the default PowerShell interface. That said, this handy module doesn’t offer all the features you can find in third-party editors. If you’re looking for a really feature-rich environment, you’re better off using third-party tools for coding. 

Conversely, the most compelling reason for using the PSReadLine module is that it’s built into PowerShell. Thus, you don’t have to worry about purchasing, downloading, or installing third-party tools.

You can also find the answers to your remaining questions about PowerShell customization in the FAQ and Resources sections below!


Why is PowerShell 7.0 failing to load PSReadLine?

It’s possible you’re using a screen reader. According to Microsoft, PowerShell 7.0 and higher automatically prevent PSReadLine from loading. That’s if you use a screen reader.

Why am I receiving an error message when I enter the Install-Module PSReadLine command?

Older versions of PowerShell required you to manually download the PSReadLine module before using it. Thus, your copy of PowerShell might not be up to date. 

Why doesn’t Microsoft include PSReadLine with Windows rather than making you download it?

In some cases, PowerShell includes the module. For example, PowerShell 5.1 includes PSReadLine version 2.0.0. Likewise, PowerShell 7.5 includes PSReadLine 2.1.0. 

Why do my modifications disappear when I close PowerShell?

When you use PSReadLine to change PowerShell’s appearance or behavior, the changes you make will only last for your session’s duration. Some people script the changes as a way of making it easy. This is to apply their customizations each time they launch PowerShell.

How can I find out about additional customization options?

PSReadLine offers numerous options for customization. With each new version, you’ll also find additional options added. One of the best ways to find out about the available options is to use the Get-PSReadLineOption cmdlet. You’ll need to import the PSReadLine module before this cmdlet will work.


TechGenix: Article on PowerShell and PowerShell Core

Learn the differences between PowerShell and PowerShell Core.

TechGenix: Article on Strict Mode in PowerShell Scripts

Read more on how to use Strict Mode in PowerShell scripts.

TechGenix: Article onComplex PowerShell Script

Find out how to easily trace a complex PowerShell script.

Microsoft: Documentation for the PSReadLine Module

Discover Microsoft’s documentation for the PSReadLine Module. 

GitHub: PSReadLine 

Find PSReadLine on GitHub.

Access PSReadLine in the PowerShell Gallery.

About The Author

Leave a Comment

Your email address will not be published. Required fields are marked *

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top