Error: “File cannot be loaded because the execution of scripts is disabled on this system”

Problem: You’re trying to run a Windows Power shell script, but you are getting an error “File cannot be loaded because the execution of script is disabled on this system.” This happens even though you changed the Execution-Policy on the powershell.

Solutioin: If you are executing the power shell by typing the powershell.exe, you may be running the 32bit version of the power shell, and you changed the execution policy on the 64 bit version. You need to go to %windir%\SysWOW64\WindowsPowerShell\v1.0\Powershell.exe and change the execution-policy.

The Set-ExecutionPolicy cmdlet enables you to determine which Windows PowerShell scripts (if any) will be allowed to run on your computer. Windows PowerShell has four different execution policies:

  • Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode.
  • AllSigned – Only scripts signed by a trusted publisher can be run.
  • RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
  • Unrestricted – No restrictions; all Windows PowerShell scripts can be run.

To assign a particular policy simply call Set-ExecutionPolicy followed by the appropriate policy name. For example, this command sets the execution policy to RemoteSigned:

Set-ExecutionPolicy RemoteSigned
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s