PowerShell has a feature that specifies the condition under which the PowerShell loads the configuration files and run the scripts.
In plain words, they are some kind of barrier. If certain conditions are not met then the configuration files or scripts will not be executed on the system. Different policies have different restriction access. These policies are defined for security purposes.
The multiple execution policies are:
- All Signed
- Remote Signed
Restricted – This policy permits user commands but will not run the script.
All signed – This policy can only run scripts that are signed with a digital signature.
Bypass- In this policy nothing is blocked, and no warnings are provided.
Remote Signed– The scripts that are written on the local computers can be executed without being signed under this policy.
Undefined – No execution policy is defined in the current scope.
Unrestricted – This policy run scripts that are unsigned.
Execution policy scope
The following are the various execution policy scope:
- Machine Policy
- User Policy
- Current User
- Local Machine
Machine Policy – This scope sets by the group policy for all the computer users.
User Policy – This scope sets by the Group policy for the current user of a computer.
Process – This scope only affects the current session of PowerShell.
Current User – In this scope, the execution policy affects only the current scope.
Local Machine – In this scope, the execution policy affects all the users on the current computer.
Determine your current execution policy
To get the policies for current session by running the following command.
Get-Execution Policy -list
Change the execution policy
You can also change the execution policy as per the requirement using the following command.
Set-Execution Policy -Execution Policy <Policy Name>