Execution of scripts is disabled on this system is a very common error. The error itself says that execution of any script on this system is disabled and usually, you get this error when you run any PowerShell script for the first time on any computer.
Easy Fixes
Mostly everyone is interested in easier and quicker way to fix it, so before going in depth, I will directly tell you the solution. After fixing the issue, if you are interested to know more details, please go through this tip.
To fix this issue, open Windows PowerShell as an administrator and after opening a window, execute the below command:
Set-ExecutionPolicy Unrestricted
Note: If you run the above command without administrative rights, you will get an error as below, which will tell you to open Windows PowerShell with the "Run as administrator" option.
Set-ExecutionPolicy : Access to the registry key
'HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell' is denied.
To change the execution policy for the default (LocalMachine) scope,
start Windows PowerShell with the "Run as administrator" option. To
change the execution policy for the current user, run "Set-ExecutionPolicy -Scope CurrentUser".
What This Error Means?
Let's see now what this error means. This is very common error and the error itself says that execution of any script on this system is disabled and usually, you get this error when you run any PowerShell script for the first time on any computer.
There are four different types of execution policies in PowerShell:
- Restricted: If this policy is set, then any script can't be executed.
- RemoteSigned: If this policy is set, then only downloaded script from the Internet can be executed and those scripts must be signed by the trusted publisher.
- Unrestricted: If this policy is set, then any type of script can be executed.
- AllSigned: If this policy is set, then only signed by a trusted publisher script can be executed.
Default policy of Windows PowerShell is "restricted", so to run the above script, we need to change it to "Unrestricted" by using command `Set-ExecutionPolicy Unrestricted
`.
If you want to set unrestricted for particular user or current user, then as specified in the error, you can run the below command:
Set-ExecutionPolicy -Scope CurrentUser
History
- 3rd December, 2020: Initial version