Windows PowerShell Error - The file cannot be loaded because the execution of scripts is disabled

Are you getting the error - The file cannot be loaded because the execution of scripts is disabled on this system while running the PowerShell script. If Yes, this article would help you understand the error and resolution.


There have been many cases where malicious VBS (Visual Basic Script) files, disguised as helpful pieces of software, have been sent around in emails and shared as a service to other users. VBS is commonly used to send out web surveys and contact lists, amongst other things. Unfortunately, it can also be camouflaged on any file they like, from simple image files to mp3s. Ultimately the creator will lure unsuspecting users into running the script, giving them control over their system in exchange for something as small as letting them know you ran the script to something much more malicious like complete control over your computer. These emails are becoming increasingly more prevalent and should be avoided at all costs.


The PowerShell execution policy addresses issue by not restricting the PowerShell for script execution. If the user tries executing the script manually, the error - File cannot be loaded because the execution of scripts is disabled on this system is generated. You can consider PowerShell execution policies as child locks in the car that serves as a safety belt for scripts.

The Windows PowerShell has the following execution policies

  • Restricted –You cannot execute any PowerShell scripts. You can run individual commands on the PS console.

  • AllSigned – It allows the execution of the scripts digitally signed by a trusted publisher. This certificate should be trusted by the computer as well.

  • RemoteSigned- In this policy, you can run any signed (trusted publisher) PowerShell script that was not created on the system where you are executing it. It is the default execution Windows PowerShell policy on Windows servers. However, you do not need digital signatures on scripts if you develop scripts locally.

  • Unrestricted – It does not put any restrictions on the execution of PS scripts. No restrictions; all scripts can be run. It has the risk of running malicious code. It warns the user before running scripts downloaded from the internet.

  • Bypass: Windows PowerShell does not block any scripts and no warnings are raised in this policy. Avoid this policy.

  • Undefined: The undefined policy states that no execution policy is set in the current scope. If the execution policy is undefined, the effective execution policy is Restricted for Windows clients and RemoteSigned for Windows Server.

Check the current Windows PowerShell execution policy

To check the current execution policy, you can run the command – get-executionpolicy as shown below.


Check the current Windows PowerShell execution policy
Set the Execution Policy for Windows PowerShell script

You can use the cmdlet Set-ExecutionPolicy to specify an execution policy. For example, the following code sets the policy to remotesigned.

Set-ExecutionPolicy remotesigned
get-executionpolicy
Set the Execution Policy

Similarly, the following code sets the Windows PowerShell execution policy to unrestricted.

set-executionpolicy unrestricted
 get-executionpolicy

43 views0 comments