Windows PowerShell Set-ExecutionPolicy

Windows PowerShell Set-ExecutionPolicy

It comes as a shock to realize that by default, and by design, PowerShell code just won’t execute because of security concerns.  Fortunately you can change this behavior easily with Set-ExecutionPolicy.PowerShell Set-ExecutionPolicy

Set-ExecutionPolicy Topics


PowerShell Pre-requisites and Checklist

In the case of Windows 7 and later, you don’t need to download any extra files, just: ‘Add Feature’ –> Windows PowerShell.  However, for older operating systems, there are different versions of PowerShell for XP, Windows Server 2003 and Vista.  For such legacy systems only, you need to download PowerShell from Microsoft’s site.

Once you have installed PowerShell 2.0 or later, I recommend choosing the ISE (Integrated Scripting Engine) version, it will save buying a text editor.

A Quick Look at Get-ExecutionPolicy

I like experiments.  Get-Execution allows us to take a snapshot before we make any changes with ‘Set’.  My other reason for introducing ‘Get’ is to help with troubleshooting why scripts are or are not working.

# PowerShell Check Scripts

PowerShell Execution Policy Values

Restricted (Default)
RemoteSigned (Guy’s favourite. Local scripts OK)
Unrestricted (Gung-ho setting, useful for testing)
AllSigned (Secure but a pain to setup)
Bypass (Never used)
Undefined (Tricky setting)


Not only is this a job that needs doing so that all your other PowerShell scripts work, but also changing the script execution behaviour gives you valuable experience with the ‘Set’ verb.

# PowerShell Set Script Behaviour
Set-ExecutionPolicy RemoteSigned

Note : Because all that you get is the message below, you may wish to append this line:


Researching Set-ExecutionPolicy

These simple mini PowerShell tutorials will help you to use Get and Set-Executionpolicy to find out where your scripts fail to run.

Help With Set-ExecutionPolicy Parameters

# PowerShell Set-ExecutionPolicy Parameters
Get-Help Set-ExecutionPolicy

Checking the help file may reveal useful parameters, for instance -List may help with troubleshooting, see more below.

Troubleshooting Set-ExecutionPolicy

While you do all of the above and configure Set-ExecutionPolicy scripts may still not run because of Group Policy restrictions.  Here are the factors to consider:

 Computer Group Policy > User Group Policy > Process (session) execution policy > User execution policy > Computer execution policy.

# PowerShell Set-ExecutionPolicy List
Get-Help Set-ExecutionPolicy -List

Typical Results From Listing ExecutionPolicies

Scope ExecutionPolicy
—– —————
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser RemoteSigned
LocalMachine RemoteSigned

See more PowerShell ISE »

Summary of Get-ExecutionPolicy

Having to adjust Get-ExecutionPolicy is the price we pay for security, administrator must be allowed to turn off PowerShell code to stop hackers or their viruses gaining control.  Set-ExecutionPolicy tackles the specific problem that your PowerShell script will not run.  Fortunately if you don’t like this behavior you can change it easily with Set-ExecutionPolicy.

If you like this page then please share it with your friends


See more Windows PowerShell tutorials

PShell Home   • Introduction   • Dreams   • 3 Key Commands   • PowerShell Help About   • Get-Help

PowerShell v 3.0   • Set-ExecutionPolicy   • Get-Command   • Cmdlet scripts   • Import-Module

PowerShell Version Check   • Backtick   • PowerShell examples   • PowerShell ISE   • Get-Member

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.