Table of Contents
Windows Execution Policy
When trying to run a PowerShell script from the PowerShell console, we received this error message, and the script cannot be run.
In some cases, it’s a The file is not digitally signed. You cannot run this script on the current system. For more information about running scripts and setting execution policy.
This is due to the Windows PowerShell execution policy being set to prevent untrusted scripts which can affect your Windows client environment. Execution policies are security settings that determine the trust level for scripts run in PowerShell. The default execution policy is Restricted on client operating systems like Windows 10/11, preventing scripts from running.
You can check the current execution policy on your system using Get-ExecutionPolicy cmdlet. As you can see in the below screenshot, it’s configured to Restricted by default on Windows client operating system.
How to Fix Scripts is Disabled on This System
To fix it, let’s open Windows PowerShell as administrator then run the below command to set the execution policy to RemoteSigned
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Force
Read more about the available execution policy on Windows machines from this post. Below is a quick snapshot about the execution policies.
You can also use Set-ExecutionPolicy Unrestricted to remove all restrictions on your security policy However, the RemoteSigned execution policy is the good option because it allows you to run all signed scripts downloaded from the internet and the scripts that you create manually on your computer.
Once you have changed the execution policy, you should be able to run scripts without the error.
PS C:\> Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
PS C:\> Get-ExecutionPolicy
RemoteSigned
PS C:\> .\processes.ps1
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
117 8 1968 8132 0.17 3636 0 AggregatorHost
330 20 8068 28592 0.64 7104 2 ApplicationFrameHost
359 22 9512 30624 0.30 9204 1 ApplicationFrameHost
289 15 4124 19312 0.06 9856 1 backgroundTaskHost
480 20 1784 5700 0.47 644 0 csrss
355 18 1928 5688 1.80 728 1 csrss
435 20 1924 6248 1.30 5804 2 csrss
392 16 3520 18924 1.48 3844 1 ctfmon
392 16 3500 19136 1.34 4936 2 ctfmon
144 9 1744 10136 0.16 1248 1 dllhost
Run scripts without admin rights
What if you can’t set the Execution Policy by running PowerShell as Administrator? To set the execution policy for the current user scope, use the following command:
Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser
The default scope is LocalMachine, which sets the policy for all users of the current machine. But the CurrentUser scope takes precedence. You can run the Get-ExecutionPolicy -List to get more details.
Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine Restricted
Bypass ExecutionPolicy Temporarily for a Session
In case, if you want to run a script only once. You can bypass the execution policy just for a one-time session. In the command prompt, type the following command:
Set-ExecutionPolicy -ExecutionPolicy Bypass Process
PS C:\> Set-ExecutionPolicy -ExecutionPolicy Bypass Process
PS C:\> Get-ExecutionPolicy
Bypass
PS C:\> Get-ExecutionPolicy -List
Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Bypass
CurrentUser Undefined
LocalMachine Restricted
PS C:\> C:\Users\bonben\processes.ps1
Handles NPM(K) PM(K) WS(K) CPU(s) Id SI ProcessName
------- ------ ----- ----- ------ -- -- -----------
117 8 1996 8152 0.25 3636 0 AggregatorHost
334 20 8176 29040 0.70 7104 2 ApplicationFrameHost
372 22 9528 29604 0.34 9204 1 ApplicationFrameHost
460 19 1772 5656 0.80 644 0 csrss
355 18 1884 5828 3.88 728 1 csrss
447 20 2028 6312 2.38 5804 2 csrss
405 16 3628 19064 2.17 3844 1 ctfmon
408 16 3612 19276 1.47 4936 2 ctfmon
149 9 1728 10420 0.17 1248 1 dllhost
253 28 6552 15004 0.42 5624 1 dllhost
Once you close the PowerShell window, the current PowerShell session ends, and the Bypass is also closed with it. This allows you to run a PowerShell script temporarily while keeping the Execution Policy settings for all other PowerShell sessions.
When running the script in PowerShell ISE. You can bypass the execution policy by selecting a block of the script and then hitting F8 (Run Selection).
Conclusion
The running scripts is disabled on this system error in PowerShell can be frustrating, but it is easily fixed by changing the execution policy. By understanding execution policies and following the steps outlined in this article, you can enable script execution and take advantage of PowerShell’s powerful automation capabilities.
Not a reader? Watch this related video tutorial: