PSReadline 2.0 not working on Windows 10 1809

  • Context:

I’m running a Windows 10 1809 at home and encountered something weird about PSReadline.
You know PSReadline is the module from Jason Shirk that enables great command line editing in the PowerShell console host.
It maintains an history of commands accross consoles and the ability to search the history (it works using CTRL+R, the same way a Bash shell works), and much more!

  • Issue:

As you can see below in the picture. I’m running a En-US input language with a french keybord layout.
The module version 2.0 that shipped in Windows is loaded but the history isn’t maintained. That’s why I cannot search the history and invoke the following method although the class exists:


NB: This method only exist in version 2.0. It does not exist in version 1.2 that shipped in Windows 10 1803.
It throws the following error:
“The type initializer for ‘Microsoft.PowerShell.PSConsoleReadLine’ threw an exception.”

  • Solution:

I had a look at the issues on GitHub and I’m not the first one who noticed this issue.

Because Jason wrote the following , I went this route:

If you’d rather not use PsGet, you can just download the file and extract the contents into your C:\Users\[User]\Documents\WindowsPowerShell\modules\PSReadLine folder. (You may have to create these directories if they don’t exist.)

I also needed to modify the Execution policy:

Note that if you’ve an Application Control solution, nothing is signed digitally:

if (-not(Test-Path -Path ~\Documents\WindowsPowerShell\modules -PathType Container)) {
md ~\Documents\WindowsPowerShell\modules
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
$HT = @{
Uri = ''
OutFile = "~/Downloads/"
UseBasicParsing = [switch]::Present
Verbose = [switch]::Present
Invoke-WebRequest @HT
$HT = @{
Path = "~/Downloads/"
DestinationPath = "~\Documents\WindowsPowerShell\modules\PSReadLine"
Force = [switch]::Present
Verbose = [switch]::Present
Expand-Archive @HT
dir ~\Documents\WindowsPowerShell\modules\PSReadline |
Unblock-File -Verbose
Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned -Verbose -Force
view raw fix-PSReadline.ps1 hosted with ❤ by GitHub
  • Caveat

The above solution works in a admin console, the command history is maintained and is searchable 🙂
But it still doesn’t work with a filtered admin token in a non-admin console 😦

1 thought on “PSReadline 2.0 not working on Windows 10 1809

  1. Hi
    if the profile has been relocated into onedrive folder the path in the script will be broken.
    use :
    if (!(Test-Path -Path “$(Split-Path $profile)\Modules” -PathType Container)) { New-Item -ItemType “directory” “$(Split-Path $profile)\Modules” }
    to locate the Modules folder within the same folder as the $profile script
    and if you chose to do so you also need to change the DestinationPath for the Expand-Archive:
    DestinationPath = “$(Split-Path $profile)\Modules\PSReadLine”
    and the unblock to :
    dir “$(Split-Path $profile)\Modules\PSReadLine” | Unblock-File -Verbose

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.