You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Running script from WSL with noninteractive flag will show "SecurityError: AuthorizationManager check failed." #17623
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
Could you try with -noprofile argument ? /mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -noprofile -file test.ps1
sun123t2@G15:~/code/tries/ps$ /mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -file ./test.ps1
SecurityError: AuthorizationManager check failed.
sun123t2@G15:~/code/tries/ps$ /mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -noprofile -file ./test.ps1
SecurityError: AuthorizationManager check failed.
sun123t2@G15:~/code/tries/ps$ unblock-file
-bash: unblock-file: command not found
sun123t2@G15:~/code/tries/ps$ /mnt/c/Program\ Files/PowerShell/7/pwsh.exe
PowerShell 7.2.5
Copyright (c) Microsoft Corporation.
https://aka.ms/powershell
Type 'help' to get help.
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Distrod\home\sun123t2\code\tries\ps> Unblock-File .\test.ps1
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Distrod\home\sun123t2\code\tries\ps> .\test.ps1
.\test.ps1: File \\wsl.localhost\Distrod\home\sun123t2\code\tries\ps\test.ps1 cannot be loaded. The file \\wsl.localhost\Distrod\home\sun123t2\code\tries\ps\test.ps1 is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy, see about_Execution_Policies at https://go.microsoft.com/fwlink/?LinkID=135170.
PS Microsoft.PowerShell.Core\FileSystem::\\wsl.localhost\Distrod\home\sun123t2\code\tries\ps> exit
sun123t2@G15:~/code/tries/ps$ /mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -noprofile -file ./test.ps1
SecurityError: AuthorizationManager check failed.
sun123t2@G15:~/code/tries/ps$
Piping script into pwsh's stdin seems working. Is there any way to disable the prompt (version, path, help, etc.) when piping, just like opening it with -file?
You are running powershell built for Windows on Linux, and I'm afraid you will get undefined behaviors. Different code paths are enabled when building for Unix platforms, and thus the Windows build powershell is bound to have issues when running in Linux environment. The recommendation is to install PowerShell in WSL and use that instead.
You are running powershell built for Windows on Linux, and I'm afraid you will get undefined behaviors. Different code paths are enabled when building for Unix platforms, and thus the Windows build powershell is bound to have issues when running in Linux environment. The recommendation is to install PowerShell in WSL and use that instead.
I Agree with you but the issue is related to specific PR #13120 , do you want another PR to remove the 13120 ? I don't understand.
I think it's different. #13120 is to address an issue that happened when running pwsh.exe from Windows within the WSL file system. But this issue is about running pwsh.exe directly in WSL.
I think it's different. #13120 is to address an issue that happened when running pwsh.exe from Windows within the WSL file system. But this issue is about running pwsh.exe directly in WSL.
Yes but the new default WSL Host has been changed, so the PR13120 need an update to declare the new set (\\wsl\, \\wsl.localhost\) for Windows Build > 20175. (\\wsl$\ is still present for retro-compatible)
I could create a new issue if you prefer, showing that I can't execute a script if the path is '\wsl.localhost\Ubuntu-20.04\home\flavien\test.ps1 on the last Windows Version, because it's not declared in the security zone. (I haven't test)
And after, it will maybe solve the current issue :
/mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -file '\\wsl\Ubuntu-20.04\home\flavien\test.ps1' => KO, path is not trusted
/mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -file '\\wsl.localhost\Ubuntu-20.04\home\flavien\test.ps1' => KO, path is not trusted
/mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -file '\\wsl$\Ubuntu-20.04\home\flavien\test.ps1' => OK, path is trusted
Activity
fMichaleczek commentedon Jul 5, 2022
I can't reproduce it.
Could you try with -noprofile argument ?
/mnt/c/Program\ Files/PowerShell/7/pwsh.exe -noninteractive -executionpolicy unrestricted -noprofile -file test.ps1Could you try to unblock your script file ?
https://support.servicenow.com/kb?id=kb_article_view&sysparm_article=KB0713009
leoleoasd commentedon Jul 5, 2022
doesn't work either.
leoleoasd commentedon Jul 5, 2022
My WSL version:
suntt2019 commentedon Jul 5, 2022
I can reproduce.

fMichaleczek commentedon Jul 5, 2022
The PR #13120 declared \\wsl$ as a security zone when analysing a script.
PowerShell/src/System.Management.Automation/engine/Utils.cs
Line 736 in b5277c0
But starting WSL Build 20175, they change the \\wsl$ prefix to \\wsl
WSL/release-notes#build-20175
But starting WSL Build 21354, they change the \\wsl prefix to \\wsl.localhost
WSL/release-notes#build-21354
So the issue #13106 is came back.
The WSL >20175 need a improvement to declare the new path and handle security (don't trust \\wslfake by example)
fMichaleczek commentedon Jul 5, 2022
/cc Dongbo Wang (@daxian-dbw)
leoleoasd commentedon Jul 5, 2022
Is there any temporary workaround for this?
leoleoasd commentedon Jul 5, 2022
Piping script into pwsh's stdin seems working. Is there any way to disable the prompt (version, path, help, etc.) when piping, just like opening it with
-file?fMichaleczek commentedon Jul 5, 2022
Yuxuan Lu (@leoleoasd) the \\WSL$ is still working, so if you force the path, PowerShell should be OK with that.
daxian-dbw commentedon Jul 5, 2022
You are running powershell built for Windows on Linux, and I'm afraid you will get undefined behaviors. Different code paths are enabled when building for Unix platforms, and thus the Windows build powershell is bound to have issues when running in Linux environment. The recommendation is to install PowerShell in WSL and use that instead.
fMichaleczek commentedon Jul 5, 2022
I Agree with you but the issue is related to specific PR #13120 , do you want another PR to remove the 13120 ? I don't understand.
daxian-dbw commentedon Jul 5, 2022
I think it's different. #13120 is to address an issue that happened when running
pwsh.exefrom Windows within the WSL file system. But this issue is about runningpwsh.exedirectly in WSL.fMichaleczek commentedon Jul 5, 2022
Yes but the new default WSL Host has been changed, so the PR13120 need an update to declare the new set (\\wsl\, \\wsl.localhost\) for Windows Build > 20175. (\\wsl$\ is still present for retro-compatible)
I could create a new issue if you prefer, showing that I can't execute a script if the path is '\wsl.localhost\Ubuntu-20.04\home\flavien\test.ps1 on the last Windows Version, because it's not declared in the security zone. (I haven't test)
And after, it will maybe solve the current issue :
Added temporary solution for pasting image inside WSL
daxian-dbw commentedon Jul 7, 2022
Flavien MICHALECZEK (@fMichaleczek) Is that Windows 11? Please open a new issue for that, thanks!
fMichaleczek commentedon Jul 7, 2022
Dongbo Wang (@daxian-dbw) At this moment, it think it's Windows 10 Insider and Windows 11.