Saturday, February 18, 2012

Execution Policy in PowerShell


When you go to run a powershell script for the first time, it might fail. The reason is that by default the Execution Policy is set to not execute scripts (for security).

To check the current policy, type:

Get-ExecutionPolicy

The execution policies you can use are:

Restricted - Scripts won’t run.
RemoteSigned - Scripts created locally will run, but those downloaded from the Internet will not (unless they are digitally signed by a trusted publisher).
AllSigned - Scripts will run only if they have been signed by a trusted publisher.
Unrestricted - Scripts will run regardless of where they have come from and whether they are signed.
You can set PowerShell’s execution policy by using the following cmdlet:


To change the current policy, simply type:

Set-ExecutionPolicy <policy name>

No comments: