Home » PowerShell » PowerShell – Running scripts is disabled on this system [Fix]

PowerShell – Running scripts is disabled on this system [Fix]

While running a PowerShell script, if you get an error message, cannot be loaded because running scripts is disabled on this system it is because the PowerShell execution policy is set up by default as Restricted and doesn’t allow running the script.

It throws an exception message as “cannot be loaded because running scripts is disabled on this system

running scripts is disabled on this system
running scripts is disabled on this system

PowerShell Scripts Disabled error message as below

.\Get-Printers.ps1: File CL\Get-Printers.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at http://go.microsoft.com/fwlink/?LinkID=135170

PowerShell has built-in security features implemented. The PowerShell Execution policy is a safety feature that controls the conditions to run scripts and load configuration. The Execution Policy in PowerShell is set up to avoid running malicious scripts in your system.

In this article, I will explain different ways to fix file cannot be loaded because running scripts is disabled on this system.

Let’s understand how to enable the execution of running PowerShell script using different execution policies.

Solution: Running scripts is disabled on this system

PowerShell Execution Policy in Restricted mode avoids running script to ensure safety.

Cool Tip: Use Get-ExecutionPolicy to know the default policy applied to your system.

Using RemoteSigned Execution Policy

RemoteSigned execution policy is a more secure option. On enabled, it allows local scripts to run. All other scripts from outside require signed by a trusted publisher.

Set-ExecutionPolicy RemoteSigned 
  • Set up RemoteSigned execution policy
  • Allows to run the local script.
  • Now if you try to run .ps1 file, it won’t give you the running script is disabled on this system error.

Cool Tip: How to fix the script is not digitally signed error in PowerShell!

Using UnRestricted Execution Policy

UnRestricted is the default execution policy set up on the non-windows systems. If you enabled this policy on the system, PowerShell can run any unsigned script file.

You can change the execution policy using the Set-ExecutionPolicy cmdlet.

Set-ExecutionPolicy Unrestricted
  • Warns the administrator about the policy change and security risk associated with UnRestricted mode.
  • If you select option, Y or Yes to All, it will apply the policy.
  • After setting up the UnRestricted execution policy, if you try to run the ps1 file, it won’t give the running script is disabled on system error.
Set-ExecutionPolicy Unrestricted to enable script
Set-ExecutionPolicy Unrestricted to enable the script

Cool Tip: How to use the multiline command in PowerShell!

Using ByPass Execution Policy

Using the bypass execution policy, nothing is blocked and if you try to run a script, it won’t give your a warning or prompt for confirmation.

With the ByPass policy, scripts run temporarily with lower security.

powershell -executionpolicy ByPass -File .\Get-Printers.ps1
  • runs ps1 script file with lower security and executes it.
  • Once your close the PowerShell session, it will also close ByPass with it.
ByPass - To fix running scripts disabled on this system
ByPass – To fix running scripts disabled on this system

Using PowerShell ISE

If you don’t want to set an execution policy and still want to run the script inside the ps1 file, the best workaround is to open the script file in PowerShell ISE.

Select all the code in the script and hit the F8 button to execute the script.

Note: Don’t use F5 for execution, else it will try to run a ps1 file and throw a file cannot be loaded error.

fix for running script disabled
Select Code-F8 to fix the file cannot be loaded error

This way, you won’t require any permissions or any kind of running script is disabled on this system error.

Cool Tip: How to add a new line to a string or variable in PowerShell!

Conclusion

I hope the above article to fix the file cannot be loaded because running scripts is disabled on this system error using the set-executionpolicy helpful to solve your problem.

Use the RemoteSigned execution policy to avoid running any malicious scripts or if a script is local, open the PowerShell script, select all code, and hit F8 to execute it.

You can find more topics about PowerShell Active Directory commands and PowerShell basics on the ShellGeek home page.

Leave a Comment