PowerShell lets you automate almost anything on a Windows system. By default, when you try to execute a custom or downloaded PowerShell script, it will throw the “Script cannot be loaded because running scripts is disabled on this system” error.
This error happens because of the Restricted execution policy. In order to execute scripts, you need to set different execution policy. In case you are wondering, here’s how to change the PowerShell execution policy in Windows 10.
What Are Execution Policies?
You can think of execution policies like a condition. A condition needs to be met to execute certain configurations or scripts. If not, the configuration or script will not run as expected.
Now, even though an execution policy can block certain configuration files or scripts from running, the policies are not a security measure. In fact, they can be easily bypassed. In Microsoft words, execution policies are just basic rules. These rules prevent you from unintentionally violating the policies.
PowerShell has six different execution policies. They are as follows.
1. Restricted Execution Policy
As you can tell from the name itself, Restricted policy is the most limited policy. The policy is applied by default on all Windows 10 PCs. Under this policy, you can only run individual commands. You cannot run any PowerShell scripts, configuration files, or module script files.
2. All Signed Execution Policy
When set, the All Signed policy only lets you run signed PowerShell scripts. This condition applies to your own custom scripts too. If the script publisher is not yet classified as trusted or untrusted, you will be prompted to choose one.
3. RemoteSigned Execution Policy
RemoteSigned policy lets you run both the scripts downloaded from the internet and the ones you create. While the scripts created on your local computer require no digital signature, scripts downloaded from the internet require a digital signature from a trusted publisher. That being said, if there is no digital signature for the downloaded scripts, you can still run them by manually unblocking the script using Unblock-File cmdlet. For Windows servers, RemoteSigned is the default execution policy.
4. Unrestricted Execution Policy
The name says it doesn’t it? Under the Unrestricted policy, you can run both downloaded and your own scripts created on the local computer without any restrictions. However, PowerShell will display a warning message when running scripts or configurations downloaded from the internet. Unrestricted is the default policy for the non-Windows system.
5. Bypass Execution Policy
Bypass policy is a step higher than Unrestricted. Under this policy, no script or configuration file is blocked. In fact, this policy will not even show any warning messages whatsoever. Generally, this policy is used as part of a larger application that has its own policies and security implementations. General users should almost never apply this policy.
6. Undefined Execution Policy
Undefined policy means that there is no execution policy in the current scope. If all the scopes are undefined, then the effective policy is Restrictive. If you read earlier, Restrictive is the default policy for all regular Windows systems (Pro and Home).
Now that you know what the execution policies actually mean, follow the below steps to change PowerShell execution policy in Windows 10. The blow steps work in Windows 7 and Windows 8 too, no matter the PowerShell version.
Change Execution Policy in PowerShell
1. To change the execution policy in PowerShell, you need to have administrator privileges. So, search for PowerShell in the start menu, right-click on it and select “Run as Administrator”.
2. The first thing you need to do is to check the current execution policy. That way, you will know whether you need to change the execution policy or not. So, execute the below command and PowerShell will instantly tell which execution policy is currently active. As you can see, in my case, it is Restricted.
3. To change or set the execution policy, execute the below command. Of course, if you’d like to use some other execution policy, replace RemoteSigned with the name of other execution policies.
Note: If you are regular home or power user who wishes to execute custom or downloaded PowerShell scripts, I’d recommend you go with the RemoteSigned execution policy. RemoteSigned execution policy offers a good balance between basic security and ease of use.
4. As soon as you execute the above command, you will be asked to confirm your action. Type A in the PowerShell window and press Enter to confirm the execution policy change.
5. To verify the policy change, execute the Get-ExecutionPolicy cmdlet again and you should see it return RemoteSigned.
That is all. It is simple to change the PowerShell execution policy.