Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:380 char:43
+             if ((Get-PSReadLineKeyHandler -Key Spacebar).Function -eq ...
+                                           ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand

Get-PSReadLineKeyHandler : A parameter cannot be found that matches parameter name 'Key'.
At line:383 char:43
+             if ((Get-PSReadLineKeyHandler -Key Enter).Function -eq 'O ...
+                                           ~~~~
    + CategoryInfo          : InvalidArgument: (:) [Get-PSReadLineKeyHandler], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.GetKeyHandlerCommand

This appears everytime whenever I open my powershell. What can I do to fix this?

Looking for a solution.

2

There are 2 best solutions below

0
On BEST ANSWER

You need to update the PSReadLine module. Run:

Install-Module PsReadLine -Force
0
On

I had the same exact issue. It occurred for me when trying to change my theme in the oh-my-posh init line in $profile. Running Install-Module PsReadLine -Force fixed the error, but my theme still didn't change. When editing $PROFILE make sure you put in

oh-my-posh init pwsh --config "$env:POSH_THEMES_PATH/ENTER-THEME-NAME-HERE.omp.json" | Invoke-Expression

and not

oh-my-posh init pwsh --config "~/ENTER-THEME-NAME-HERE.omp.json" | Invoke-Expression

The page is wrong under the powershell tab under the Config syntax paragraph.

Hope this helps.