Home » PowerShell » Use SetExecutionPolicy to Fix Running Scripts is Disabled on this System

Use SetExecutionPolicy to Fix Running Scripts is Disabled on this System

“The error message ‘cannot be loaded because running scripts is disabled on this system’ typically arises when attempting to execute a PowerShell script while the default PowerShell execution policy is set to ‘Restricted.’

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 and causes the exception message”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

In this article, I will explain different ways to fix ps1 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.

Using Set-ExecutionPolicy Cmdlet to Fix 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 to Enable Running PowerShell Script

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 to Enable PowerShell Scripts

UnRestricted execution policy in PowerShell allows running any script without regard to whether it is signed or not.

You can set up 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 to Fix Script is Disabled on this System

Using the bypass execution policy, nothing is blocked and if you try to run a script, it won’t give you 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 you close the PowerShell session, it will also close the ByPass policy.
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