Saturday, November 12, 2011

PowerShell: Execution of scripts is disabled

This information is available on many sites, but I'm tired of searching for it every few months when I switch laptops/tablets.

Whenever you try to run an unsigned PowerShell script, you get the following message: "File C:\Custom\Test.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see "get-help about_signing" for more details."

I certainly believe Microsoft is doing the right thing with keeping PowerShell script execution secure with the proliferation of malware and 99%+ of Windows users don't even know about PowerShell.

Changing the PowerShell security setting is a simple affair. Open PowerShell as an Administrator and run the following: Set-ExecutionPolicy

Your choices are:
Restricted (default) - Which stops all unsigned scripts from running.
AllSigned - This allows only signed scripts to run.
RemoteSigned (my recommendation) - Allows local scripts to run, but all downloaded or remotely executed must be signed.
Unrestricted (not recommended) - This allows all scripts to execute, whether from an e-mail, website or instant message.

Syntax: Set-ExecutionPolicy RemoteSigned

1 comment:

  1. Note. You can also verify the settings for your execution policy by typing the following at the PowerShell command prompt and then pressing ENTER: