0

I try to run the command ng in a PowerShell, but systems require that the script must be signed.

I try to change my policy of execution.

This is my current configuration Get-ExecutionPolicy -List:

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

Then, I run the next command Set-ExecutionPolicy -Scope CurrentUser Unrestricted

The change on the policy it's OK, but appear an error telling another policy defined in a most especific ambit deny the value.

And the command ng still not running with the error, \AppData\Roaming\npm\ng.ps1 it's not signed digitally.

Can you help me? Ty everyone

R. Richards
  • 24,603
  • 10
  • 64
  • 64
  • [_"MachinePolicy. Set by a Group Policy for all users of the computer"_](https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.security/set-executionpolicy?view=powershell-7.2#parameters) -- this is propably what prevents you from changing the policy for the current user. It would make sense that a group policy, which is set by administrators, cannot be overridden by the user. You can try running the script like this: `powershell -ExecutionPolicy bypass -File $env:AppData\npm\ng.ps1` – zett42 Sep 18 '22 at 11:01
  • I have tried to run the command, same error. + FullyQualifiedErrorId : UnauthorizedAccess – FrysonDevs Sep 18 '22 at 11:10
  • Then you have to ask the admin to make an exception in the group policy for your machine or user. – zett42 Sep 18 '22 at 11:18
  • And do you know how can I make that exception? Im the admin of the system. Ty for the answer. – FrysonDevs Sep 18 '22 at 12:27
  • https://4sysops.com/archives/set-powershell-execution-policy-with-group-policy/ – zett42 Sep 18 '22 at 13:37

0 Answers0