ITExperience.NET Rotating Header Image

File cannot be loaded because the execution of scripts is disabled on this system error in PowerShell



When you try to run a Powershell script (PS1), you may get the following error:

File xyz.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details. At line:1 char:2

The reason for this error is the security setting on your pc that does not allow you to execute a script.  This is the so-called Execution Policy. By default, the Execution Policy is set to Restricted. This setting means that you may not run any PS1 script at all.

An overview of the policy levels:

Restricted: Individual cmdlets can run, but not saved Powershell scripts. This is the default setting.
AllSigned: Scripts can run, but must have a digital signature even if written on the local computer. Prompts you before running scripts from trusted publishers.
RemoteSigned: Scripts written on the local computer do not need a digital signature, but any script downloaded from outside (email, IM, Internet) must have a signature to execute. 
Unrestricted: Any script can run, but scripts downloaded from outside will run with a warning.

If you’re working on a desktop and just experimenting with PowerShell, the best is to set the policy-level to Unrestricted. This allows you do everything with annoying security boundaries. Just be careful not to run every script you download from the internet :)
If you’re working in a production environment and only want to run self-written scripts, the RemoteSigned level should be loosy enough.

To change the Execution Policy to Unrestricted, type the following command in Powershell

Set-ExecutionPolicy Unrestricted

To change the Execution Policy to RemoteSigned (to run your own scripts), type the following command in Powershell

Set-ExecutionPolicy RemoteSigned

If you have any question left, feel free to leave a comment. By choosing to be informed when someone posts a reply, you will immediately receive an email after someone replies.

 

5 Comments

  1. Jimmy says:

    I run the (Set-ExecutionPolicy Unrestricted )and it worked fine ..that is  

    (Quote)

  2. Kamil says:

    Thanks for the info, its help me a lot.

    BTW, make sure you run PowerShell as Administrator to execute Set-ExecutionPolicy  

    (Quote)

  3. OmarOZ7 says:

    Changing Execution Policy

    The best way to set execution policy is to use the Set-ExecutionPolicy cmdlet. Set-ExecutionPolicy has one parameter – executionpolicy which can take one of four values:

    Restricted
    All Signed
    Remote Signed
    Unrestricted

    Alternatively it is possible to edit the following registry key

    HKEY_Local_Machine\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.Powershell\ExecutionPolicy  

    (Quote)

  4. Dave says:

    LOL

    That is freaking hilarious. I bet this guy would lock keys in his glove-box so he has keys if he ever gets locked out of his car.  

    (Quote)

  5. Roy says:

    How can you run a script which will allow scripts to run, if running a script is disabled in the first place?

    Fricken stupid-  

    (Quote)

Leave a Reply

Comments without hyperlinks are immediately visible. However, if you post a comment that includes a hyperlink, your comment requires approval. This can take up to one day.