PowerShell 5.1 PSReadline Rename

This is an “Auto-fix” script for the PowerShell 5.1 directory name error which blocks updates and execution of Command-Lets.



Source code:

https://github.com/Stevennagle/WinScripts/blob/main/AutoFixPS51DirReName.ps1



Explanation:

In Windows PowerShell 5.1 the “PSReadline” module was spelled with a lowercase “L.” This was changed to an uppercase “L” for the release of PowerShell 6. This can create complications with several features. This directory name mismatch produces errors when attempting to update CmdLets.



Resolution:

You can run this script from a Microsoft Windows Admin CMD window:

C:\WINDOWS\system32> powershell.exe -ExecutionPolicy Bypass -File <yourFilePath>\AutoFixPS51DirName.ps1

  1. cmd /c ren “C:\Program Files\WindowsPowerShell\Modules\PSReadline” PSReadLine
  2. #Optional: Remove-Module PSReadline
  3. Import-Module PSReadLine
  4. Update-Help -Module PSReadLine -Force


Example:

Initial Error:



Folder Location:




Solution: