PowerShell: Running script from WSL with noninteractive flag will show "SecurityError: AuthorizationManager check failed."

Prerequisites

Steps to reproduce

 /mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -file ./xxx.ps1

Expected behavior

runs successfully since there is a -executionpolicy unrestricted flag

Actual behavior

SecurityError: AuthorizationManager check failed.

Error details

I don’t know how to provide this since I’m starting a .ps1 file and the session ends before the file’s execution

Environment data

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

Visuals

image

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 16 (3 by maintainers)

Commits related to this issue

Most upvoted comments

@leoleoasd the \\WSL$ is still working, so if you force the path, PowerShell should be OK with that.

home> echo "Write-Host Test" > test.ps1
home> /mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -file '\\wsl$\Ubuntu-20.04\home\flavien\test.ps1'