Execution Policy

Execution Policy in PowerShell is the safety feature which controls the execution of scripts and cmdlets from violating them unintentionally.

It allows the system to restrict the user by giving the message to identify the script is signed by trusted publisher. However the user can bypass the restriction using Set-ExecutionPolicy cmdlet.

There are generally 4 main types of Execution Policy that are used:

  1. Restricted
  2. Unrestricted
  3. AllSigned
  4. RemoteSigned

Run PowerShell as Administrator

To get the current Execution Policy set by the system use below cmdlet:

Get-ExecutionPolicy

To change or set or bypass the default policy use ‘Set-ExecutionPolicy’ with

Set-ExecutionPolicy RemoteSigned

Execution Policy

1. Restricted:

  1. This is default setting on Windows client operating system computers.
  2. With this policy no scripts will be allowed to run on the system
  3. This setting in place will allow user to run individual cmdlets but not the scripts

2. Unrestricted

  1. This is the default execution policy for non-windows computers and cannot be changed.
  2. With this policy set on your Windows computer you will be able to run any script but there exists the risk of running malicious scripts.
  3. However the system itself warns the user prior running the scripts in unrestricted execution policy mode that are downloaded from internet

3. AllSigned

  1. This is the default execution policy on Windows Server operating system computers
  2. With this setting in place user can run their own script and scripts that are trusted by developer

4. RemoteSigned

  1. This is the default execution policy on Windows Server operating system computers
  2. With this setting in place user can run their own script and scripts that are trusted by developer

5. Default

  1. This setting when used will set the Execution Policy to default state as per the operating system running.
  2. i.e It will keep Restricted for Windows Client computers and RemoteSigned for all Windows Server computers

References : Microsoft Docs

Leave a Reply

Your email address will not be published.