{"id":8551,"date":"2007-02-15T15:35:00","date_gmt":"2007-02-15T15:35:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2007\/02\/15\/execution-policy-and-vista\/"},"modified":"2019-02-18T13:20:45","modified_gmt":"2019-02-18T20:20:45","slug":"execution-policy-and-vista","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/execution-policy-and-vista\/","title":{"rendered":"Execution Policy and Vista"},"content":{"rendered":"<p>Some of you may be getting an error when trying to set the execution policy on a new install of Windows PowerShell in Vista:<\/p>\n<blockquote>\n<p>&nbsp;PS C:\\Users\\leonard&gt; Set-ExecutionPolicy unrestricted<br \/>Set-ExecutionPolicy : Access to the registry key &#8216;HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell&#8217; is denied.<br \/>At line:1 char:20<br \/>+ Set-ExecutionPolicy&nbsp; &lt;&lt;&lt;&lt; unrestricted<\/p>\n<\/blockquote>\n<p>This behavior is by design. As a system-wide default that affects all users, the ExecutionPolicy is stored in the HKLM registry hive. PowerShell users on XP and Windows Server 2003 likely didn&#8217;t see this as most users login with administrative privileges. In Vista, this changed with the advent of <a class=\"\" title=\"User Account Control\" href=\"http:\/\/www.microsoft.com\/windows\/products\/windowsvista\/features\/details\/useraccountcontrol.mspx\" target=\"_blank\">User Account Control<\/a>. Unless explictly requested, processes started by an Administrator account will run as a standard user and not Administrator.<\/p>\n<p><strong>The resolution here is to start PowerShell as an Administrator and then run the command. You can do this most easily by right-clicking the PowerShell icon in the Start Menu and selecting &#8220;Run as Administrator&#8221;.<\/strong><\/p>\n<p>Why does PowerShell require administrator privileges to change the execution policy? It affects&nbsp;all users on the machine, and defines a safe default. It is not a user&nbsp;restriction, but gives a system default.<\/p>\n<p>The upshot of all this is administrators can create policies where PowerShell runs signed scripts on servers and, but don&#8217;t run on laptops by default. In the past, popular script malware&nbsp;often asked the user to go through a series of steps to execute a malicious script. ExecutionPolicy adds an additional layer of defense as it allows administrators&nbsp;to reduce security attack surface area and define a safe default.<\/p>\n<p>As with every time I talk about security, I want to make sure I frame this in the right context: This is defense in depth and not a silver bullet. Of course it won&#8217;t protect against a hacker extremely good at social engineering who can entice a user to enter commands directly into the console or prevent a sufficiently naive and determined user from being tricked into opening a text file with malware in notepad, starting PowerShell, and copying in the malicious script one line at a time.&nbsp;In both of these cases though,&nbsp;the attacker has control of the machine through the user so in practice the machine has already been effectively compromised before PowerShell was even started.<\/p>\n<p>&nbsp;<\/p>\n<p>Leonard Chung [MSFT]<\/p>\n<p>Windows PowerShell &amp; Microsoft Management Console Program Manager<\/p>\n<p>Visit the Windows PowerShell Team blog at: <a href=\"http:\/\/blogs.msdn.com\/PowerShell\"><strong><font color=\"#006bad\">http:\/\/blogs.msdn.com\/PowerShell<\/font><\/strong><\/a><br \/>Visit the Windows PowerShell ScriptCenter at: http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/p>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Some of you may be getting an error when trying to set the execution policy on a new install of Windows PowerShell in Vista: &nbsp;PS C:\\Users\\leonard&gt; Set-ExecutionPolicy unrestrictedSet-ExecutionPolicy : Access to the registry key &#8216;HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell&#8217; is denied.At line:1 char:20+ Set-ExecutionPolicy&nbsp; &lt;&lt;&lt;&lt; unrestricted This behavior is by design. As a system-wide default that affects all users, [&hellip;]<\/p>\n","protected":false},"author":600,"featured_media":13641,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-8551","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Some of you may be getting an error when trying to set the execution policy on a new install of Windows PowerShell in Vista: &nbsp;PS C:\\Users\\leonard&gt; Set-ExecutionPolicy unrestrictedSet-ExecutionPolicy : Access to the registry key &#8216;HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\PowerShell\\1\\ShellIds\\Microsoft.PowerShell&#8217; is denied.At line:1 char:20+ Set-ExecutionPolicy&nbsp; &lt;&lt;&lt;&lt; unrestricted This behavior is by design. As a system-wide default that affects all users, [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8551","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/users\/600"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/comments?post=8551"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/8551\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media\/13641"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/media?parent=8551"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=8551"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=8551"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}