Skip to content
This repository was archived by the owner on Sep 11, 2021. It is now read-only.
This repository was 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

@Fred-Vatin

Description

@Fred-Vatin

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions