PowerShell Logo Small

Set-ExecutionPolicy



This is the built-in help made by Microsoft for the command 'Set-ExecutionPolicy', in PowerShell version 2 - as retrieved from Windows version 'Microsoft® Windows Vista™ Ultimate ' PowerShell help files on 2016-06-23.

For PowerShell version 3 and up, where you have Update-Help, this command was run just before creating the web pages from the help files.

SYNOPSIS

Changes the user preference for the Windows PowerShell execution policy.

SYNTAX


Set-ExecutionPolicy [-ExecutionPolicy] {Unrestricted | RemoteSigned | AllSigned | Restricted | Default | Bypass | Undefined} [[-Scope] {Process |
CurrentUser | LocalMachine | UserPolicy | MachinePolicy}] [-Force] [-Confirm] [-WhatIf] [<CommonParameters>]



Search powershellhelp.space

DESCRIPTION


The Set-ExecutionPolicy changes the user preference for the Windows PowerShell execution policy.

To run this command on Windows Vista, Windows Server 2008, and later versions of Windows, you must start Windows PowerShell with the "Run as admi
nistrator" option, even if you are a member of the Administrators group on the computer.

The execution policy is part of the security strategy of Windows PowerShell. It determines whether you can load configuration files (including yo
ur Windows PowerShell profile) and run scripts, and it determines which scripts, if any, must be digitally signed before they will run.

For more information, see about_Execution_Policies.



<

RELATED LINKS

Online version: http://go.microsoft.com/fwlink/?LinkID=113394
Get-ExecutionPolicy
Set-AuthenticodeSignature
Get-AuthenticodeSignature
about_Execution_Policies
about_Signing

REMARKS

<

Examples


-------------------------- EXAMPLE 1 --------------------------

C:\PS>set-executionpolicy remotesigned



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








-------------------------- EXAMPLE 2 --------------------------

C:\PS>Set-ExecutionPolicy Restricted

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 admini
strator for more information.
At line:1 char:20
+ set-executionpolicy <<<< restricted



Description
-----------
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.








-------------------------- EXAMPLE 3 --------------------------

C:\PS>invoke-command -computername Server01 -scriptblock {get-executionpolicy} | set-executionpolicy -force



Description
-----------
This command gets the execution policy from a remote computer and applies that execution policy to the local computer.

The command uses the Invoke-Command cmdlet to send the command to the remote computer. Because you can pipe an ExecutionPolicy (Microsoft.PowerSh
ell.ExecutionPolicy) object to Set-ExecutionPolicy, the Set-ExecutionPolicy command does not need an ExecutionPolicy parameter.

The command does have a Force parameter, which suppresses the user prompt.








-------------------------- EXAMPLE 4 --------------------------

C:\PS>set-executionpolicy -scope CurrentUser -executionPolicy AllSigned -force

C:\PS> get-executionpolicy -list

Scope ExecutionPolicy
----- ---------------
MachinePolicy Undefined
UserPolicy Undefined
Process Undefined
CurrentUser AllSigned
LocalMachine RemoteSigned

C:\PS> get-executionpolicy
AllSigned



Description
-----------
This example shows how to set an execution policy for a particular scope.

The first command uses the Set-ExecutionPolicy cmdlet to set an execution policy of AllSigned for the current user. It uses the Force parameter t
o suppress the user prompts.

The second command uses the List parameter of Get-ExecutionPolicy to get the execution policies set in each scope. The results show that the exec
ution policy that is set for the current user differs from the execution policy set for all users of the computer.

The third command uses the Get-ExecutionPolicy cmdlet without parameters to get the effective execution policy for the current user on the local
computer. The result confirms that the execution policy that is set for the current user takes precedence over the one set for all users.








-------------------------- EXAMPLE 5 --------------------------

C:\PS>set-executionpolicy -scope CurrentUser -executionPolicy Undefined



Description
-----------
This command uses an execution policy value of Undefined to effectively remove the execution policy that is set for the current user scope. As a
result, the execution policy that is set in Group Policy or in the LocalMachine (all users) scope is effective.

If you set the execution policy in all scopes to Undefined and the Group Policy is not set, the default execution policy, Restricted, is effectiv
e for all users of the computer.