I have a couple of lines in my Windows Powershell profile referencing the PSReadLine module:
# Alternative autocomplete for Tab-key Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete # Autocomplete with arrow-keys based on history Set-PSReadLineKeyHandler -Key UpArrow -Function HistorySearchBackward Set-PSReadLineKeyHandler -Key DownArrow -Function HistorySearchForward
I’m trying to set up a similar profile for Powershell 7/Core, but I’m having some issues as my Documents folder is on a file server (cached locally). Which means the RemoteSigned executionpolicy refused to deal with both my profile and modules installed within the CurrentUser scope.
I know I could set the ExecutionPolicy to Unrestricted, but I thought I’d try to see if I could get things to work without opening it entirely.
I self-signed the profile and installed the other modules referenced in the profile to the AllUsers scope. This seems to have worked as everything except for PSReadLine works now.
When I start a new PS7 tab in Terminal I get the following error message (for each of the PSReadLine lines in the profile:
Set-PSReadLineKeyHandler: \\[MyDocumentsFolder]\PowerShell\Microsoft.PowerShell_profile.ps1:11 Line | 11 | Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete | ~~~~~~~~~~~~~~~~~~~~~~~~ | The 'Set-PSReadLineKeyHandler' command was found in the module 'PSReadLine', but the module could not be loaded. For more information, run 'Import-Module PSReadLine'.
And when I try to run Import-Module PSReadLine i get the following:
Import-Module: Errors occurred while loading the format data file: C:\Program Files\PowerShell\Modules\PSReadLine\2.2.0\PSReadLine.format.ps1xml, , C:\Program Files\PowerShell\Modules\PSReadLine\2.2.0\PSReadLine.format.ps1xml: The file was skipped because of the following validation exception: File C:\Program Files\PowerShell\Modules\PSReadLine\2.2.0\PSReadLine.format.ps1xml cannot be loaded because its operation is blocked by software restriction policies, such as those created by using Group Policy..
I’m quite sure that it’s not related to any GPO because PSReadLine works without a hitch in my WinPS profile/sessions.
As you can see the version that’s installed right now is the 2.2.0 beta4 version but it’s not the specific version of PSReadLine that is the problem.
As part of my attempts to get this solved (and get access to some functionality unique for the 2.2.0 version) I ran:
Install-Module PSReadLine -AllowClobber -AllowPreRelease -Force -Scope AllUsers
Initially I got another error message that I’m no longer able to reproduce where PS7 asked me for each of the three PSReadLine lines in the profile what I wanted to do and gave me a couple of options: Never Run, Don’t Run, Run Once, Always Run or something like that. If I chose one of the Run options it would just give an error and continue to the next line.
I was pretty sure that I never chose the Never Run option, but I’m wondering if I might have accidentally done that and caused PS7 to block PSReadLine. If so, how do I unblock it.
If it’s something else entirely… How do I get it to work?