Set-ExecutionPolicy

 

Additional Resources for Set-ExecutionPolicy

 

Changing the Windows PowerShell Script Execution Policy

http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/set-executionpolicy.mspx

 

 

SYNOPSIS

Changes the user preference for the execution policy of the shell.

 

SYNTAX

Set-ExecutionPolicy [-executionPolicy] {<Unrestricted> | <RemoteSigned> | <AllSigned> | <Restricted> | <Default>} [-whatIf] [-confirm] [<CommonParameters>]

 

DETAILED DESCRIPTION

The Set-ExecutionPolicy changes the user preference for the execution policy of the shell. The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including your Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

 

PARAMETERS

 

-executionPolicy <ExecutionPolicy>

Specifies a new execution policy for the shell. The parameter name ("-Name") is optional.

 

Valid values are:

 

·          Restricted: Does not load configuration files or run scripts. "Restricted" is the default.

·          AllSigned: Requires that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the local computer.

·          RemoteSigned: Requires that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.

·          Unrestricted: Loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.

 

The following lists the acceptable values for this parameter:

 

·          Unrestricted

·          RemoteSigned

·          AllSigned

·          Restricted

·          Default

 

Required?

true

Position?

1

Default value

N/A

Accept pipeline input?  

true (ByValue)

Accept wildcard characters? 

false

 

-whatIf

Describes what would happen if you executed the command without actually executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

-confirm

Prompts you for confirmation before executing the command.

 

Required?

false

Position?

named

Default value

 

Accept pipeline input?  

false

Accept wildcard characters? 

false

 

<CommonParameters>

This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUT TYPE

System.String

 

NOTES

 

For more information, type "Get-Help Set-ExecutionPolicy -detailed". For technical information, type "Get-Help Set-ExecutionPolicy -full".

 

When you use Set-ExecutionPolicy, the new user preference is written to the registry and remains unchanged until you change it.

 

However, if the "Turn on Script Execution" Group Policy is enabled for the computer or user, the user preference is written to the registry, but it is not effective, and Windows PowerShell displays a message explaining the conflict. You cannot use Set-ExecutionPolicy to override a group policy, even if the user preference is more restrictive than the policy.

 

For detailed information about Windows PowerShell execution policy, including the group policies, type "Get-Help About_Signing".

 

When specifying multiple values for a parameter, use commas to separate the values. For example, "<parameter-name> <value1>, <value2>".

 

EXAMPLE 1

 

set-executionpolicy remotesigned

 

This command sets the user preference for the shell execution policy to RemoteSigned.

 

EXAMPLE 2

 

Set-ExecutionPolicy Restricted

 

This command attempts to set the execution policy for the shell to "Restricted." The "Restricted" setting is written to the registry, but because it conflicts with a group policy, it is not effective, even though it is more restrictive than the policy.

 

Set-ExecutionPolicy : Windows PowerShell updated your local preference successfully, but the setting is overridden by the group policy applied to your system. Due to the override, your shell will retain its current effective execution policy of "AllSigned". Contact your group policy administrator for more information.

At line:1 char:20

+ set-executionpolicy  <<<< restricted

 

RELATED LINKS

Get-ExecutionPolicy

Set-AuthenticodeSignature

Get-AuthenticodeSignature

about_signing