Change the user preference for the execution policy of the shell.
Syntax
Set-ExecutionPolicy [-executionPolicy] Policy
{Unrestricted | RemoteSigned | AllSigned | Restricted | Default}
[-whatIf] [-confirm] [CommonParameters]
Key
-executionPolicy Policy
A new execution policy for the shell.
Valid values:
Restricted
Do not load configuration files or run scripts.
This is the default.
AllSigned
Require that all scripts and configuration files be signed
by a trusted publisher, including scripts that you write on the
local computer.
RemoteSigned
Require that all scripts and configuration files downloaded
from the Internet be signed by a trusted publisher.
Unrestricted
Load all configuration files and run all scripts.
If you run an unsigned script that was downloaded from the
internet, you are prompted for permission before it runs.
-whatIf
Describe what would happen if you executed the command without actually
executing the command.
-confirm
Prompt for confirmation before executing the command.
CommonParameters:
-Verbose, -Debug, -ErrorAction, -ErrorVariable, -OutVariable.
Examples
Set the user preference for the shell execution policy to RemoteSigned and then display the effective execution policy. The commands are separated by a semicolon (;)
PS C:\>set-executionpolicy remotesigned; get-executionPolicy
Get information about the Authenticode signature for two files:
PS C:\>get-AuthenticodeSignature C:\NewScript.ps1 E:\OtherScript.ps1
Runing unsigned scripts
If you set the PowerShell execution policy to RemoteSigned it is still possible to run unsigned scripts:
Save the script file on your computer, Right-click the file, and click "Properties."
At the bottom of the dialogue box click "Unblock."
Alternatively just copy the text into a brand new text file and save it with a .ps1 extension.
64 bit Machines
These
will include both the 64 and 32bit version of Powershell, they each can have different execution policies, so you need to set both.
“Laughing on the way to your execution is not generally understood by less-advanced life forms, and they call you crazy” - Richard Bach
Related Powershell Commands:
Set-AuthenticodeSignature - Sign a powershell script
Get-ExecutionPolicy - Get the execution policy for the shell