Windows users can run their PowerShell scripts using the PowerShell terminal with just a single command. But, sometimes, usually for first-time users, the error message “Powershell Cannot Be Loaded Because Running Scripts Is Disabled on This System” may appear on the blue terminal. There can be exactly two reasons behind this problem. One is the execution policy restrictions over all the scripts and the other one is the script from the unknown or untrusted vendor. Just follow this easy solution to identify and fix the problem.
Fix 1 – Run the PowerShell in administrator mode
One of the most frequent mistakes we do is to try to run the script in the PowerShell terminal without proper administrative rights.
1. You have to press the Win key and type “powershell“.
2. Then, right-click on the “Windows PowerShell” and tap “Run as administrator“.
Once the terminal opens up with proper administrative rights, you should try to run the shell script again and test if it is working.
Fix 2 – Check & modify the Execution policy
Execution Policy does prohibit you from running some scripts.
1. Now, just press the Win key and type “powershell“.
2. Then, right-click on the “Windows PowerShell” and tap “Run as administrator“.
3. Once the PowerShell terminal opens up, type this code and hit Enter to know the current policy status of the scripts.
Get-ExecutionPolicy -List
4. Now, you can see the complete list of execution policies for all the users/ user groups.
Usually, the default scope of execution is set to “Undefined” status.
5. Now, copy-paste this code to set the execution policy to the Unrestricted mode*.
Set-ExecutionPolicy Unrestricted
6. Now, you will be asked “Do you want to change the execution policy“. Just, type “Y” in the command and hit Enter to apply the change.
Now, you can easily run the script on your system. PowerShell won’t restrict the execution of the script anymore.
This way, you won’t face the trouble of running the script at all.
*NOTE –
The powerShell execution policy is vital security that prohibits any unknown, malicious scripts from running on the system. So, you should not leave it to the available setting. It is recommended that once you have executed the script, set the execution policy to ‘AllSigned’ or ‘RemoteSigned’.
1. Open the PowerShell as an administrator.
2. Once you have opened it, run this command to restrict any script from executing on your system.
Set-ExecutionPolicy Restricted
After restricting the execution policy, no scripts will be executed.
Additionally, if you want, you can toggle the security level to a more lenient one. There are 4 basic security levels that you can set the execution policy to. There are –
1. Restricted – This mode does prohibit any script from executing on the system. Restricted mode is the highest level of execution policy that you can place.
2. Allsigned – Only all the signed scripts by trusted publishers can be run on the system. You can’t run any third-party unknown script in this mode.
3. RemoteSigned – Remotely signed scripts can be run on the system as well as scripts that are written on the local computer.
4. Unrestricted – Unrestricted mode, as the name suggests, allows you to run any script on the system. This can be dangerous as malicious scripts won’t be blocked.
Suppose you are trying to set the execution policy to “RemoteSinged“, and execute this code in an elevated PowerShell terminal.
Set-ExecutionPolicy RemoteSigned
You may close the Command Prompt terminal.