How can I change the policy that will allow me to run the PowerShell script on my machine?
PowerShell screen
I have tried checking the solution described there:
How do you successfully change execution policy and enable execution of PowerShell scripts
I changed the settings in
MMC (Computer Configuration -> Administrative Templates -> Windows Components)
and
regedit (HKEY_LOCAL_MACHINE -> SOFTWARE -> Policies -> Microsoft -> Windows -> Powershell)
but all the time I am getting that error on the attached screen
Set-ExecutionPolicy : Windows PowerShell updated your execution policy successfully, but the setting is overridden by a
policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution
policy of RemoteSigned. Type "Get-ExecutionPolicy -List" to view your execution policy settings. For more information p
p lease see "Get-Help Set-ExecutionPolicy".
At line:1 char:46
- … -ne ‘AllSigned’) { Set-ExecutionPolicy -Scope Process Bypass }; & ‘C …
-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- CategoryInfo : PermissionDenied: (:) [Set-ExecutionPolicy], SecurityException
- FullyQualifiedErrorId : ExecutionPolicyOverride,Microsoft.PowerShell.Commands.SetExecutionPolicyCommand
How do you successfully change execution policy and enable execution of PowerShell scripts
HKEY_LOCAL_MACHINE -> SOFTWARE -> Policies -> Microsoft -> Windows -> Powershell
changed to "ByPass"
Computer Configuration -> Administrative Templates -> Windows Components
Turn Script execution: enabled
Execution policy: allow all scripts
2
Answers
Try this and work up.
You can try other values for scope.
Get the values for the enum listed for that parametr:
You’ve (successfully) updated your script execution policy via a GPO (Group Policy Object; via MMC, as described in your question).
GPO-based execution policies have the highest precedence among all the scopes in which you can set a policy;
Get-ExecutionPolicy -List
shows the scopes in descending order of precedence.Your error message shows an attempt to set the execution policy for the current process (
-Scope Process
).Because an execution policy in the process scope is overridden by GPO-based execution policies, the process-level attempt is ineffective, and that’s what the error message is trying to tell you.
You can ignore the error if the GPO-based execution policy is still permissive enough to allow you to run your script, but I suspect that the process-level attempt to set the execution policy stems from running your scripts via File Explorer’s context menu, whose invocation command is – unfortunately – defined that way.
HKEY_CLASSES_ROOTMicrosoft.PowerShellScript.1shell Command
) and remove theSet-ExecutionPolicy
call from it.