Change Execution Policy in the Registry

When executing scripts you may encounter errors
A common error occurs during the all important ‘Set-ExecutionPolicy’ call –

Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied.
+ Set-ExecutionPolicy  <<<< RemoteSigned

This usually happens when you have certain permissions defined on your machine.

To modify ‘ExecutionPolicy’ directly without executing from script we can hack the registry directly where powershell is registered

Method

  1. Open ‘run’, type ‘regedit’ and hit enter
  2. Using the navigation tree drill down this path:
    HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
  3. If it does not exist then create a new key by right-clicking–>new key:
      Type: REG_SZ
      Name: "ExecutionPolicy"
      value: "RemoteSigned"

The value can be one of four:

  • Restricted
  • AllSigned
  • RemoteSigned
  • Unrestricted

5 Responses to Change Execution Policy in the Registry

  1. Kevin says:

    Thank You, this is exactly what I was looking for. Also make sure you are running PowerShell in Admin mode.

  2. David Homer says:

    Hi,

    Thanks for the post this was very helpful.

    There are a couple of caveats here such as if Group Policy is used then these settings are ignored. There are a couple of additional values for newer versions of PowerShell which I mentioned here.

    http://david-homer.blogspot.co.uk/2015/01/using-regedit-to-view-and-set.html?showComment=1421841024440#c3741975792417314596

    Dave

  3. David Homer says:

    Hi,

    Thanks for the post this was very helpful.

    There are a couple of caveats here such as if Group Policy is used then these settings are ignored. There are a couple of additional values for newer versions of PowerShell which I mentioned here.

    http://david-homer.blogspot.co.uk/2015/01/using-regedit-to-view-and-set.html

    Dave

  4. Munmi says:

    Works perfectly. Thank you sooou much.

  5. sitrucj says:

    YUPPPPPPPPPPPPPPPPP. TY 😀

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: