Windows 10 Change PowerShell Execution Policies

Windows PowerShell has four different execution policies:

Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
AllSigned – Only scripts signed by a trusted publisher can be run.
RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
Undefined – No execution policy has been set.

If the execution policy is not set and not configured, it is displayed as “Undefined”. Here is how you can see the current value.

Note* all the commands should be run inside powershell.

How to see the PowerShell Execution Policy

Get-ExecutionPolicy -List

Change the PowerShell Execution policy for a process

Powershell.exe -ExecutionPolicy Unrestricted -File c:\data\test.ps1

Tip: For an open PowerShell console, you can switch the execution policy using the command:

Set-ExecutionPolicy Unrestricted -Scope Process

Change PowerShell Execution policy for the current user

Set-ExecutionPolicy Unrestricted -Scope CurrentUser

Tip: If the policy is not set after the command above, try to combine it with the -Force argument, like this:

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

Change the global PowerShell Execution policy

Set-ExecutionPolicy Unrestricted -Scope LocalMachine

Change PowerShell Execution policy with a Registry tweak

It is possible to change the execution policy with a Registry tweak for both the current user and the computer. Here is how it can be done.
HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

Reference: https://winaero.com/blog/change-powershell-execution-policy-windows-10/

Leave a Reply

Your email address will not be published. Required fields are marked *