Context
You are now eager to test PowerShell 6, but in the current version (6.2) PSReadLine and your usual shortcuts are not working at all.
When you try to have a look at the PSReadLine configuration you get the following errors:
Get-PSReadLineKeyHandler : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception. At line:1 char:1 + Get-PSReadLineKeyHandler + ~~~~~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-PSReadLineKeyHandler], TypeInitializationException + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.GetKeyHandlerCommand
Get-PSReadLineOption : The type initializer for 'Microsoft.PowerShell.PSConsoleReadLine' threw an exception. At line:1 char:1 + Get-PSReadLineOption + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [Get-PSReadLineOption], TypeInitializationException + FullyQualifiedErrorId : System.TypeInitializationException,Microsoft.PowerShell.GetPSReadLineOption
Workaround
There is a GitHub issue here but it has been closed.
However, according to Steve LEE:
There isn’t a new beta coming soon, but you can pick up the nightly build which has the fix.
So what you can do is to:
- Rename the C:\Program Files\PowerShell\6\Modules\PSReadLine folder.
Rename-Item -Path 'C:\Program Files\PowerShell\6\Modules\PSReadLine' -NewName PSReadLine.old
- Download the PSReadLine.zip file from here.
Invoke-WebRequest -Uri 'https://ci.appveyor.com/api/buildjobs/3ejmf131eakd0th7/artifacts/bin%2FRelease%2FPSReadLine.zip' -OutFile C:\Temp\PSReadline.zip
- Unzip the file to the C:\Program Files\PowerShell\6\Modules\PSReadLine folder.
- Restart your PowerShell 6 console
Expand-Archive -Path C:\temp\PSReadline.zip -DestinationPath 'C:\Program Files\PowerShell\6\Modules'