Console extension PSReadline now part of PowerShell 5 in Windows 10

A while back, I reviewed the free PSReadline PowerShell module that extends the console with a variety of features. I just learned that the module is now a part of PowerShell 5. A few differences exist from the module that I tested with PowerShell 4. In this post, I summarize the main new features that the module brings to PowerShell 5.

The new PowerShell console that comes with Windows 10 offers a range of improvements. The PSReadline module adds new functionality to the console that can increase your productivity when editing PowerShell commands. The module is located in C:\Program Files\WindowsPowerShell\Modules and is imported automatically when you launch a PowerShell console.

Update: As noted by a reader, the module is not part of the PowerShell 5 Production Preview for previous Windows versions.

PSReadline location

PSReadline location

Syntax highlighting is one of the features that the module brings to the PowerShell 5 console:

Syntax highlighting

This improves readability and reduces the risk of syntax errors. PSReadline can also detect some syntax errors. You will see a red greater-than sign at the end of the prompt:

Syntax error

However, this doesn’t work for all syntax errors. In contrast to the previous PSReadline, the PowerShell 5 version doesn’t prevent you from executing commands that contain syntax errors.

If you often copy and paste text in the console, you will like that the console now behaves like any other Windows application. That is, you can highlight text with the cursor keys while pressing the SHIFT keys. You can then copy the text with CTRL+C and paste with CTRL+V. It is hard to believe, but this wasn’t possible in Windows 8.1 and PowerShell 4.

Selecting text on PowerShell 5 console

Selecting text on the PowerShell 5 console

Of course, you can also use the mouse to highlight text. The old way (highlighting text as a block) is gone. If you are editing a command that has multiple lines, you have to use the left and right cursor keys. Up-arrow and down-arrow don’t work.

Higlight text with mutliple lines

You can start a new line by pressing SHIFT+ENTER.

One of my favorite features of the PSReadline module is the history search. To search backward, you have to press CTRL+R; to search forward, CTRL+S.

Backward search in history

As you can see in the screenshot, the module also finds text in the middle of a command and not just at the beginning. This history is still available if you close the console. If you open a second a console, the history of the first console is immediately available.

Useful is menu completion that presents a list of options when you press CTRL+SPACE. When you switch to Emacs mode, you can also work with bash-style TAB completion. The following command changes your console to Emacs mode:

If you now start entering a command and press the TAB key, you will get a list of possible options.

Bash-style tab completion

To view all key bindings in Emacs mode, you can use the following command:

Emacs mode key bindings
Emacs mode key bindings

To switch back to Windows mode, you need the next command:

You can also change key bindings. For instance, if you just like the bash-style auto-completion in Windows mode, the following command changes the key binding accordingly:

PSReadline offers a variety of settings that you can change with the next command:

With the Get-Help cmdlet, you can learn more about the module:

You can also disable the module by removing it:

If you don’t like the module, you can just delete it in C:\Program Files\WindowsPowerShell\Modules. Make sure that no PowerShell console is open when you delete the module. You might want to create a copy of the module first. You can then restore it later if you change your mind.

Join the 4sysops PowerShell group!

Your question was not answered? Ask in the forum!

0
8 Comments
  1. Windos 5 years ago

    Strictly speaking, PSReadLine doesn't 'come with' PowerShell 5. It comes per-installed on Windows 10.

    If you install PowerShell 5 on an older OS (via the Windows Management Framework 5 Production Preview), you miss out on PSReadLine unless you install it yourself... which is easy to do with PowerShell 5's Install-Module cmdlet!

    0

  2. Thanks for the hint! I added a note to the article. Hopefully, Microsoft will add all modules that are available on Windows 10 once the final of PowerShell 5 for the other Windows version is out. It will probably cause some compatibility headaches if they don't.

    0

  3. carefree 5 years ago

    Looks like they've updated PSReadLine in Windows 10 Build 10532.

    Ctrl-Space and highlight via up/down-arrow key both work now.

    PS C:\WINDOWS\system32> get-host

    Name : ConsoleHost
    Version : 5.0.10532.0

    Pressed Ctrl-Space on Get-h
    PS C:\WINDOWS\system32> Get-History
    Get-Help Get-History Get-Host Get-HotFix

    0

  4. Oh yeah, CTRL+SPACE works now. Strange that it didn't work when I first tried it. Thanks! I updated the article.

    But highlighting with up/down-arrow still doesn't work with code in multiple lines. How did you open a new line? I pressed SHIFT+ENTER.

    0

  5. carefree 5 years ago

    No, you're correct about the highlighting. I was not trying it on two lines of code. Up/down-arrow does not work with multiple lines of code, I was highlighting multiple window lines.

    Also tried it on Windows 8.1 Powershell 5 with PSReadLine 1.0.0.13 installed and it does not work for code, or anything for that matter.

    BTW thanks for the tip about the Ctrl-Space combo--that's a real gem.

    0

  6. F-Seven 5 years ago

    This module seems to kill both CTRL+F and F7 functions which is a shame considering how much it adds.

    0

  7. Herb Martin 4 years ago

    This issue of Windows 10 vs. PowerShell 5 can be very confusing and here is my simplified understanding of how approach such items:

    PowerShell may be supplemented with many features from OTHER products, including Microsoft products, such as Exchange, SQL Server, etc. -- and these features will vary across versions of that product.

    Sure, that's simple.  Easy to understand.

    However, Windows 10 (and other versions of the OS) are treated as "products" also, so even though PowerShell 5 comes with Windows 10, upgrading PowerShell to version 5 on Windows 7 doesn't include all of the features added by the Windows 10 'product' -- nor probably all of those added by Windows 8/8.1 either.

    Some of the cool new functions just aren't part of PowerShell itself but are added by the OS (or other products.)

    0

    • Author

      You are right, PowerShell 5 is not always PowerShell 5. But it is like that with many software products. They often depend on the features of the platform they run on.

      What counts as being a part of PowerShell and what counts as an extension is another question. For me, everything that is installed on a fresh Windows installation is part of PowerShell. So PSReadline is a part of PowerShell where as the Active Directory module is not. But I admit that this is a matter of taste.

      0

Leave a reply to carefree Click here to cancel the reply

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

*

© 4sysops 2006 - 2020

CONTACT US

Please ask IT administration questions in the forums. Any other messages are welcome.

Sending

Log in with your credentials

or    

Forgot your details?

Create Account