PSReadLineis one of those modules that may not immediately show its utility until regular use.

If you use the command-line of PowerShell often, PSReadLine can make your life much easier.

Updating and Loading PSReadLine

Most relatively recent versions of PowerShell have a bundled version of PSReadLine.

/wordpress/wp-content/uploads/csit/2020/12/dd806c59.png

Of course, you may want to take advantage of newer features in older PowerShell versions.

In case PSReadLine is not already imported, use

to start using the features right away.

To confirm you are using the latest version, read on!

/wordpress/wp-content/uploads/csit/2020/12/63987953.png

Beginning with PowerShell 7.0, PowerShell skips auto-loading PSReadLine on Windows if a screen reader program is detected.

Currently, PSReadLine doesn’t work well with screen readers.

The default rendering and formatting of PowerShell 7.0 on Windows works properly.

/wordpress/wp-content/uploads/csit/2020/12/e2eba771.png

you’re free to manually load the module if necessary.

Windows PowerShell 5.x

There are generally two steps to updating PSReadLine with Windows PowerShell 5.0 or 5.1.

First, you oughta ensure you are running version

or higher of PowerShellGet.

To do this, you oughta fire off the following command in an elevated Windows PowerShell session.

Next, see to it that all PowerShell sessions are closed and in an elevatedcmd.exeprompt launch the following code.

Features of PSReadLine

What can we do with PSReadLine?

There are a number of very cool features that can help you with your command-line experience.

Below you will see how several features work in practice.

Multi-Line Editing

Taking the same command series above, how do we split this across multiple lines?

What about when you aren’t sure command to use?

Predictive Intellisense to the rescue!

Predictive Intellisense

First, we need to enable Predictive IntelliSense.

Now we can test this out using the same command that we just ran.

it’s possible for you to see that after just typingGetwe already see the command offered for completion.

it’s possible for you to use the right arrow (default) to accept the selection.

When using cmdlets likeConvertTo-SecureStringpasswords may be stored in the history file.

Conclusion

PSReadLine is a very useful module to enhance your command-line experience.