Published by


Brink's Avatar
Administrator

Posts: 25,652

Show Printable Version 


How to Set PowerShell Script Execution Policy in Windows 10

information   Information
The PowerShell script execution policy enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:

Execution Policy Description
Restricted No PowerShell scripts can be run. Windows PowerShell can be used only in interactive mode. This means that you can only run individual commands. You can't run scripts under this policy, regardless of where the scripts came from (local or downloaded) and whether they are signed.
AllSigned Only PowerShell scripts signed by a trusted publisher can be run. When you attempt to run a signed script, you'll receive a prompt asking you to confirm that you trust the publisher.
RemoteSigned Downloaded PowerShell scripts must be signed by a trusted publisher before they can be run. Scripts that you run from the local computer don't need to be signed. There are no prompts when you attempt to run a script.
Unrestricted No restrictions; all PowerShell scripts can be run.
Undefined (default) No execution policy has been set.

This tutorial will show you different ways on how to set the PowerShell script execution policy for the current user or local machine in Windows 10.


CONTENTS:
  • Option One: To See Current PowerShell Script Execution Policies
  • Option Two: To Set PowerShell Script Execution Policy to "RemoteSigned" for Current User in Settings
  • Option Three: To Set PowerShell Script Execution Policy for Current User in PowerShell
  • Option Four: To Set PowerShell Script Execution Policy for Current User using a REG file
  • Option Five: To Set PowerShell Script Execution Policy for Local Machine in PowerShell
  • Option Six: To Set PowerShell Script Execution Policy for Local Machine using a REG file





Change PowerShell Script Execution Policy in Windows 10 OPTION ONE Change PowerShell Script Execution Policy in Windows 10
To See Current PowerShell Script Execution Policies

1. Open PowerShell.

2. Copy and paste the command below into PowerShell, and press Enter.

Get-ExecutionPolicy -List

3. You will now see all execution policies. The policies are listed in precedence order. (see screenshot below)

Click image for larger version. 

Name:	Get-ExecutionPolicy.png 
Views:	931 
Size:	19.0 KB 
ID:	87113






Change PowerShell Script Execution Policy in Windows 10 OPTION TWO Change PowerShell Script Execution Policy in Windows 10
To Set PowerShell Script Execution Policy to "RemoteSigned" for Current User in Settings

1. Open Settings, and click/tap on the Update & security icon.

2. Click/tap on For developers on the left side, check the Change execution policy to allow local PowerShell scripts to run without signing. Require signing for remote scripts. box under PowerShell on the right side, and click/tap on the Apply button. (see screenshot below)
Note   Note
If this setting is grayed out, then the execution policy for your account is already set to RemoteSigned.


Click image for larger version. 

Name:	CurrentUser_PowerShell_Execution_Policy_in_Settings.png 
Views:	753 
Size:	45.1 KB 
ID:	87112

3. You can now close Settings if you like.






Change PowerShell Script Execution Policy in Windows 10 OPTION THREE Change PowerShell Script Execution Policy in Windows 10
To Set PowerShell Script Execution Policy for Current User in PowerShell

1. Open PowerShell.

2. Copy and paste the command below into PowerShell for the execution policy your want to set, and press Enter.

Set-ExecutionPolicy Restricted -Scope CurrentUser -Force

Set-ExecutionPolicy AllSigned -Scope CurrentUser -Force

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser -Force

Set-ExecutionPolicy Unrestricted -Scope CurrentUser -Force

Set-ExecutionPolicy Undefined -Scope CurrentUser -Force

3. You can now close PowerShell if you like.






Change PowerShell Script Execution Policy in Windows 10 OPTION FOUR Change PowerShell Script Execution Policy in Windows 10
To Set PowerShell Script Execution Policy for Current User using a REG file

Note   Note
The .reg files below will modify the string value in the registry key below.

HKEY_CURRENT_USER\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

ExecutionPolicy string value

Restricted
AllSigned
RemoteSigned
Unrestricted
Undefined



1. Do step 2 (Restricted), step 3 (AllSigned), step 4 (RemoteSigned), step 5 (Unrestricted), or step 6 (Undefined) below for what you would like to do.


 2. To Set PowerShell Script Execution Policy to "Restricted" for Current User

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

CurrentUser_Restricted_PowerShell_ExcutionPolicy.reg

download


 3. To Set PowerShell Script Execution Policy to "AllSigned" for Current User

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

CurrentUser_AllSigned_PowerShell_ExcutionPolicy.reg

download


 4. To Set PowerShell Script Execution Policy to "RemoteSigned" for Current User

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

CurrentUser_Restricted_PowerShell_ExcutionPolicy.reg

download


 5. To Set PowerShell Script Execution Policy to "Unrestricted" for Current User

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

CurrentUser_Unrestricted_PowerShell_ExcutionPolicy.reg

download


 6. To Set PowerShell Script Execution Policy to "Undefined" for Current User

NOTE: This is the default setting.

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

CurrentUser_Undefined_PowerShell_ExcutionPolicy.reg

download


7. Save the .reg file to your desktop.

8. Double click/tap on the downloaded .reg file to merge it.

9. If prompted, click on Run, Yes (UAC), Yes, and OK to approve the merge.

10. You can now delete the downloaded .reg file if you like.






Change PowerShell Script Execution Policy in Windows 10 OPTION FIVE Change PowerShell Script Execution Policy in Windows 10
To Set PowerShell Script Execution Policy for Local Machine in PowerShell

Note   Note
You must be signed in as an administrator to be able to do this option.

Tip   Tip
If you get a message in red like below when setting a PowerShell execution policy, then it just means that your (current user) set execution policy will be used instead of this local machine setting. If you like, you can set your (current user) execution policy to Undefined to no longer see this message in red when setting the local machine policy.
Click image for larger version. 

Name:	message.png 
Views:	212 
Size:	48.6 KB 
ID:	87114


1. Open an elevated PowerShell.

2. Copy and paste the command below into the elevated PowerShell for the execution policy your want to set, and press Enter.

Set-ExecutionPolicy Restricted -Scope LocalMachine -Force

Set-ExecutionPolicy AllSigned -Scope LocalMachine -Force

Set-ExecutionPolicy RemoteSigned -Scope LocalMachine -Force

Set-ExecutionPolicy Unrestricted -Scope LocalMachine -Force

Set-ExecutionPolicy Undefined -Scope LocalMachine -Force

3. You can now close the elevated PowerShell if you like.






Change PowerShell Script Execution Policy in Windows 10 OPTION SIX Change PowerShell Script Execution Policy in Windows 10
To Set PowerShell Script Execution Policy for Local Machine using a REG file

Note   Note
You must be signed in as an administrator to be able to do this option.


The .reg files below will modify the string value in the registry key below.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell

ExecutionPolicy string value

Restricted
AllSigned
RemoteSigned
Unrestricted
Undefined



1. Do step 2 (Restricted), step 3 (AllSigned), step 4 (RemoteSigned), step 5 (Unrestricted), or step 6 (Undefined) below for what you would like to do.


 2. To Set PowerShell Script Execution Policy to "Restricted" for Local Machine

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

LocalMachine_Restricted_PowerShell_ExcutionPolicy.reg

download


 3. To Set PowerShell Script Execution Policy to "AllSigned" for Local Machine

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

LocalMachine_AllSigned_PowerShell_ExcutionPolicy.reg

download


 4. To Set PowerShell Script Execution Policy to "RemoteSigned" for Local Machine

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

LocalMachine_Restricted_PowerShell_ExcutionPolicy.reg

download


 5. To Set PowerShell Script Execution Policy to "Unrestricted" for Local Machine

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

LocalMachine_Unrestricted_PowerShell_ExcutionPolicy.reg

download


 6. To Set PowerShell Script Execution Policy to "Undefined" for Local Machine

NOTE: This is the default setting.

A) Click/tap on the Download button below to download the file below, and go to step 7 below.

LocalMachine_Undefined_PowerShell_ExcutionPolicy.reg

download


7. Save the .reg file to your desktop.

8. Double click/tap on the downloaded .reg file to merge it.

9. If prompted, click on Run, Yes (UAC), Yes, and OK to approve the merge.

10. You can now delete the downloaded .reg file if you like.




That's it,
Shawn