Updating help for the PSReadLine module in Windows PowerShell 5.1

Sean Wheeler

The version of the PSReadline module that shipped in Windows PowerShell 5.1 used a lowercase letter in the name. The name of the module was changed for the release of PowerShell 6. It now uses a capital L in the name.

Error updating PSReadLine help

In the example above, I am trying to update help for the PSReadLine module on my Windows computer. Take a close look at the error message. Notice the spelling of the module name in the message:

Failed to update Help for the module(s) ‘PSReadline

In PowerShell 6 and higher, the PSReadLine module is spelled with a capital L character. But the error message is using a lowercase letter.

The root cause of the error

The problem comes from Windows PowerShell 5.1. The version of the PSReadline module that shipped in Windows PowerShell 5.1 used a lowercase letter in the name. The name of the module was changed for the release of PowerShell 6. It now uses a capital L in the name.

The Update-Help cmdlet constructs the URL of the CAB file containing the updated help. The URL path is case-sensitive. The updated help files use the new name with the capital L. PowerShell 6 and higher is installed side-by-side with Windows PowerShell. When you run Update-Help, the cmdlet attempts to update the help for both versions of PowerShell. The name of the module that Update-Help uses is based on the name of the folder where the help is stored. For Windows PowerShell this is C:\Program Files\WindowsPowerShell\Modules\PSReadline.

Note that only the update of help for the Windows PowerShell location is failing.

How to fix this problem

Fortunately the fix is simple. Just rename the folder to C:\Program Files\WindowsPowerShell\Modules\PSReadLine. To rename this folder, you must be sure to close all Windows PowerShell sessions to release any open file handles on the directory. If you try to rename the folder from the PowerShell command line, you receive the following error message.

Rename-Item: Source and destination path must be different.

There are two simple ways to rename the folder.

  • From an elevated PowerShell session, run the following command:

cmd /c ren "C:\Program Files\WindowsPowerShell\Modules\PSReadline" PSReadLine

  • Use the Windows File Explorer to rename the file.

Update-Help still fails in Windows PowerShell 5.1

Even after renaming the folder, you still get the same error when you try to update help for Windows PowerShell 5.1.

The root problem in Windows PowerShell 5.1 is that the module is automatically loaded at startup using the PSReadline name (with the lowercase l). Use the following steps workaround this problem and update the help.

  1. Open an elevated powershell.exe session (Run as  Administrator).
  2. Run Remove-Module PSReadLine to remove the auto-loaded PSReadLine module.
  3. Run Import-Module PSReadLine (use PSReadLine with capital L).
  4. Then run Update-Help -Module PSReadLine -Force

These steps load the module in your session using the proper name, which allows Update-Help to use the correct name to find the help content. You may consider adding the Remove-Module and Import-Module commands to your profile script for Windows PowerShell 5.1.

In the following screen shot you can see that PSReadLine is loaded in the session using the lowercase L. After removing the module and reimporting it, the correct name is loaded in the session.

Image psr reload

2 comments

Discussion is closed. Login to edit/delete existing comments.

  • Thorsten Lambrecht 0

    One drawback is, that the about_psreadline will now be doubled and i dont find a way to access it:
    PS C:\Windows\System32\WindowsPowerShell\v1.0> get-help psreadline

    Name Category Module Synopsis
    —- ——– —— ——–
    Set-PSReadLineOption Cmdlet PSReadLine Customizes the behavior of command line editin…
    Set-PSReadLineKeyHandler Cmdlet PSReadLine Binds keys to user-defined or PSReadLine key h…
    Remove-PSReadLineKeyHandler Cmdlet PSReadLine Removes a key binding.
    Get-PSReadLineOption Cmdlet PSReadLine Gets values for the options that can be config…
    Get-PSReadLineKeyHandler Cmdlet PSReadLine Gets the bound key functions for the PSReadLin…
    about_PSReadline HelpFile
    about_PSReadLine HelpFile

    Get-Help about_psreadline now returns only this:
    Name Category Module Synopsis
    —- ——– —— ——–
    about_PSReadline HelpFile
    about_PSReadLine HelpFile

    Any clew on this?

    • Sean WheelerMicrosoft employee 1

      You have to manually delete the old help from the old location.

Feedback usabilla icon