Skip to content
This repository has been archived by the owner on Sep 11, 2021. It is now read-only.

"Scripts cannot be executed on this system." on pwsh 7 if process scope is not Unrestricted #173

Open
Fred-Vatin opened this issue May 28, 2021 · 0 comments

Comments

@Fred-Vatin
Copy link

Fred-Vatin commented May 28, 2021

Here is my config

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

I only installed PowerShell-7.1.3-win-x64.msi.

Unrestricted current user failed

I have set both local machine and current user to unrestricted but it keeps returning the error message Scripts cannot be executed on this system. It’s been fixed when I ran the Set-ExecutionPolicy Unrestricted -Force -scope Process command.

Working Policy on my system

Then I tried to run the npm-windows-upgrade command with this policy only :

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

And it worked 🎉. The process scope is only applied during session. It is reset to undefined for new session.

I didn’t try every combination but for Powershell local users, I guess it’s a common setting for pwsh 7.

I guess this needs to be mentionned for users who could face this issue.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant