Skip to content

pwsh.exe -C ./myscript.ps1 fails from WSL #13106

@stuartleeks

Description

@stuartleeks

Steps to reproduce

In WSL I created the following script file

 echo "Write-Host Hello!" > test.ps1

From WSL I attempted to run the script:

$ pwsh.exe -C ./test.ps1
./test.ps1: AuthorizationManager check failed.
$ pwsh.exe -F ./test.ps1
SecurityError: AuthorizationManager check failed.

Running the same script with Windows PowerShell succeeds:

$ powershell.exe -C ./test.ps1
Hello!

Expected behavior

I expected the script to run successfully, as it does with Windows PowerShell

Actual behavior

$ pwsh.exe -C ./test.ps1
./test.ps1: AuthorizationManager check failed.
$ pwsh.exe -F ./test.ps1
SecurityError: AuthorizationManager check failed.

Environment data

$PSVersionTable


powershell.exe:

Name                           Value
----                           -----
PSVersion                      5.1.19041.1
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.1
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1


pwsh.exe:

Name                           Value
----                           -----
PSVersion                      7.0.2
PSEdition                      Core
GitCommitId                    7.0.2
OS                             Microsoft Windows 10.0.19042
Platform                       Win32NT
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1
WSManStackVersion              3.0

Get-ExecutionPolicy -List


powershell.exe:

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine    RemoteSigned

pwsh.exe

        Scope ExecutionPolicy
        ----- ---------------
MachinePolicy       Undefined
   UserPolicy       Undefined
      Process       Undefined
  CurrentUser       Undefined
 LocalMachine    RemoteSigned

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Questionideally support can be provided via other mechanisms, but sometimes folks do open an issue to get aResolution-FixedThe issue is fixed.WG-Cmdlets-Managementcmdlets in the Microsoft.PowerShell.Management module

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions