0

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

kollodziej
  • 11
  • 5

1 Answers1

0

Try this and work up.

Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

You can try other values for scope.

Get-Help Set-ExecutionPolicy -Parameter scope

Get the values for the enum listed for that parametr:

[Microsoft.PowerShell.ExecutionPolicyScope]::GetValues([Microsoft.PowerShell.ExecutionPolicyScope])
Jordan Mills
  • 86
  • 1
  • 2
  • it worked. But now if I have few PowerShell scripts and I want to create a sequence and run them one by one after they are finished how can I do that? for example I have three scripts one.ps1, two.ps2, three.ps1 and I want a sequence: one.ps1 - wait for the end and then run next, two.ps1 - wait for the end and then run next, three.ps1 – kollodziej Aug 11 '23 at 08:49
  • Probably depends on what scope worked for you. Generally if you set it in a session, it will apply to that session and children so you can just call the three scripts. – Jordan Mills Aug 14 '23 at 22:58