How to turn on or off Windows PowerShell script execution
If you want to turn on or off Windows PowerShell script execution in Windows 10, follow this step by step guide. We will use the Registry Editor and Local Group Policy Editor to enable or disable this functionality.
Windows PowerShell is an essential and handy tool included in the Windows operating system. There are mainly two types of scripts – Signed by a trusted publisher and Local scripts. Local scripts are what you create on your personal computer, whereas the other one is what a trusted publisher has signed to perform a specific task.
Turn on or off Windows PowerShell script execution
To turn on or off Windows PowerShell script execution using Group Policy Editor, follow these steps-
- Search for gpedit.msc in the Taskbar search box.
- Click on Edit group policy in the search result.
- Go to Windows PowerShell in Computer Configuration.
- Double-click on Turn on Script Execution.
- Select the Enabled option.
- Choose an Execution Policy from the drop-down list.
- Select the Disabled option to turn off script execution.
- Click on Apply and OK.
Let’s check out these steps in detail.
At first, you will have to open the Local Group Policy Editor on your computer. For that, search for gpedit.msc
in the Taskbar search box and click on Edit group policy in the search result. After opening this tool, navigate to the following path-
Computer Configuration > Administrative Templates > Windows Components > Windows PowerShell
In the Windows PowerShell folder, you will see a setting called Turn on Script Execution. Double-click on it and select the Enabled option.
After that, choose an Execution Policy from the drop-down list. You will see these three options-
- Allow only signed scripts
- Allow local scripts and remote signed scripts
- Allow all scripts
If you want to turn off the script execution in Windows PowerShell, choose the Disabled option.
Either way, click on Apply and OK to save the change.
As said earlier, it is possible to make the same change using Registry Editor. Before that, it is recommended to create a System Restore point and backup all Registry files.
Enable or disable Windows PowerShell script execution using Registry
To enable or disable Windows PowerShell script execution, follow these steps-
- Press Win+R.
- Type regedit and press the Enter button.
- Click on the Yes button.
- Go to Windows inside HKLM key.
- Right-click on Windows > New > Key.
- Name it as PowerShell.
- Right-click on PowerShell > New DWORD (32-bit) Value.
- Name it as EnableScripts.
- Double-click on it to set the Value data as 1.
- Right-click PowerShell > New > String Value.
- Name it as ExecutionPolicy.
- Double-click on it to set the Value data as mentioned below.
If you want to learn more, keep reading.
To get started, press Win+R, type regedit
and hit the Enter button. If you see the UAC prompt, click on the Yes button to open Registry Editor on your computer. After that, navigate to the following path-
HKEY_LOCAL_MACHINESOFTWAREPoliciesMicrosoftWindows
Right-click on Windows, select New > Key, and name it as PowerShell.
You will have to create a DWORD (32-bit) Value and a String Value in the PowerShell key. For that, right-click on PowerShell > New > DWORD (32-bit) Value and name it as EnableScripts.
Double-click on EnableScripts to set the Value data as 1 or 0. If you want to enable this functionality, make it 1. Otherwise, let it be 0.
Now, you will have to set the execution policy. For that, right-click on PowerShell > New > String Value, and name it as ExecutionPolicy.
After that, double-click on it and enter the Value data as said below-
- AllSigned: Allow only signed scripts
- RemoteSigned: Allow local scripts and remote signed scripts
- Unrestricted: Allow all scripts
At last, click the OK button to save the change.
That’s all! Hope it helps.