Bart's Weblog

Just a blog…

PowerShell: ExecutionPolicy

Posted by bartvdw on 2222/0404/2008

I know I waited far too long to start working with PowerShell. But OK, here we are. And immediately encountered something. By default it sets some security related to running scripts. Only when I did what it said, I was unable to change that security!

OK in short, after you install PowerShell, it sets the “ExecutionPolicy” for scripts to “Restricted”, which means you’re not allowed to execute scripts. Not very interesting… So I used the “Set-ExecutionPolicy RemoteSigned” command to change, but this returned an error:
Set-ExecutionPolicy : Access to the registry key ‘HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell’ is denied.
At line:1 char:20
+ Set-ExecutionPolicy  <<<< RemoteSigned

  • Open registry
  • Browse to key HKLM\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell
  • If “ExecutionPolicy” does not exist, create it as REG_SZ with value “RemoteSigned”
  • Open PowerShell and use the command “Get-ExecutionPolicy” to see it is done correctly

It’s only obvious that if another security level is desired, you adapt the value… šŸ™‚


14 Responses to “PowerShell: ExecutionPolicy”

  1. Jesse said

    You *do not* need to do anything in the registry… Editing the registry is not the proper process to change this policy.

    Just running the following command is *all* that you need to do:

    PS> set-executionpolicy remotesigned

  2. Jesse said

    You need to be running PowerShell as an Administrator to change the ExecutionPolicy. That is why you got access denied…

    • Drew said

      I’m running the dang thing as an Administrator and it still refuses to let me change the ExecutionPolicy. Seems like a stupid code-block to me.

  3. Bobby said

    Jesse, not correct- even as administrator you get this error.. Going directly to the registry, however, works and you are now able to change the executionpolicy.


  4. John said

    I had the same issue, ran ps2 as admin ,and did the set-executionPolicy remotesigned, and it worked.


  5. Kyle said

    This is exactly what I needed. THANK YOU!

  6. […] pages for troubleshooting: No Comments by Kyle on March 8, 2011  •  Permalink Posted in […]

  7. Kyle said

    I resummarized this on my blog, if this helps anyone:

    Good luck!

  8. […] […]

  9. vinithra said

    hi, can anybody help me out…pls….i have a unix system and a windows2008 server….im doing ssh from the unix system to the windows server and then trying to execute a powershell script….its saying “File C:\Users\sveaisrvcd\Documents\MyScripts\Hello.ps1 cannot be loaded because the execution of scripts is disabled on this system. Please see “get-help about_signing” for more details.”. And i checked the execution-policy which shows ‘restricted’, but it is unrestricted when i check on the system directly….how can i solve this….pls help…
    thanks in advance..

  10. Tihamer said

    Nothing worked for me (even though i was running PowerShell as administrator, AND I have administrator privileges).
    I didn’t want to add the ExecutionPolicy key to my registry, so I changed registry privileges by:
    Running regedit
    Going to HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell
    Right-Clicking to Permissions
    Selecting and granting “Full Control” privileges to Users.

    It worked!
    (thanks to at

  11. Jeff said

    You will need to do it as administrator for both the 64bit and 32bit versions of Powershell.

  12. […] This post explains how to edit the registry directly. […]

  13. McBrosa said

    If none of those works try running this as admin…

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned

    For more detail:

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: