{"id":7991,"date":"2007-05-05T21:55:42","date_gmt":"2007-05-05T21:55:42","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/powershell\/2007\/05\/05\/running-scripts-downloaded-from-the-internet\/"},"modified":"2019-02-18T13:16:40","modified_gmt":"2019-02-18T20:16:40","slug":"running-scripts-downloaded-from-the-internet","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/powershell\/running-scripts-downloaded-from-the-internet\/","title":{"rendered":"Running Scripts Downloaded from the Internet"},"content":{"rendered":"<p>Over on the Microsoft.Public.Windows.PowerShell newsgroup Stefan had a number of questions about the following scenario:\n<\/p>\n<p style=\"margin-left: 36pt\">I want to start ps1 scripts over UNC paths or mapped network shares. I tried <br \/>to change the execution policy to unrestricted but I always get the <br \/>following prompt:<\/p>\n<p>Security Warning<br \/>Run only scripts that you trust. While scripts from the Internet can be <br \/>useful, this script can potentially harm your<br \/>computer. Do you want to run <a href=\"\/\/\/\\\\blablabla\\bla\">\\\\blablabla\\bla<\/a>?<br \/>[D] Do not run\u00a0 [R] Run once\u00a0 [S] Suspend\u00a0 [?] Help (default is &#8220;D&#8221;):\n<\/p>\n<p>This has confused a number of people.  That is because most of us never read the documentation.  <span style=\"font-family:Wingdings\">J<\/span>   If there is one piece of documentation you should read, it is about_signing.\n<\/p>\n<p>Chainsaws are awesome tools but if you apply them to your leg \u2013 it will be a really bad day.  <br \/>So too, scripting is an awesome tool but if you make the wrong security decisions, it is going to be a bad day.  <br \/>This is why we ship PowerShell in RESTRICTED mode which allows interactive use but does not allow scripts to be run.  As soon as you try to run a script, we give an error and tell you to read About_Signing.\n<\/p>\n<p style=\"margin-left: 36pt\"><span style=\"font-family:Consolas\">[0]PS&gt; .\\test.ps1<br \/><span style=\"color:red\">File C:\\Temp\\wmi\\test.ps1 cannot be loaded because the execution of scripts<br \/> is disabled on this system. Please see &#8220;get-help about_signing&#8221; for more details.<br \/>At line:1 char:11<br \/>+ .\\test.ps1 &lt;&lt;&lt;&lt;\n<\/span><\/span><\/p>\n<p>About_Signing is designed to layout the security decisions you need to make and then detail their risks and benefits.  Here is what it says about UNRESTRICTED:\n<\/p>\n<p>\n\t\t<span style=\"font-family:Consolas\">Unrestricted<br \/>        &#8211; Unsigned scripts can run.<br \/>        &#8211; <span style=\"color:red\">Scripts and configuration files that are downloaded from the Internet<br \/>          (including Microsoft Outlook, Outlook Express and Windows Messenger)<br \/><strong>\n\t\t\t\t<\/strong>run<strong> after warning you that the file originated from the Internet.<br \/><\/strong><\/span>        &#8211; Risks running malicious scripts.\n<\/span><\/p>\n<p>What this is saying is that various tools (like IE and Outlook) tag downloaded content with origin information.  PowerShell looks for this and when it detects that a script comes from the internet, we warn you and you have to make an explicit decision to run it or not.  Think of this as the functional equivalent of having to put your foot on the brakes before you can put your car in reverse.\n<\/p>\n<p>As a general rule, you need to be very careful running stuff you pulled down from the internet.  If you&#8217;ve reviewed the script and found it to be trustworthy, you can remove its origin information by UNBLOCKING it from the properties dialog box in Explorer (Select the object in explorer, right click, select properties, unclick BLOCKED).\n<\/p>\n<p>As a reminder, I&#8217;ve included the execution policy choices you have:\n<\/p>\n<p><span style=\"font-family:Consolas\">POWERSHELL EXECUTION POLICIES<br \/>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>The PowerShell execution policies are:<\/p>\n<p>    Restricted<br \/>        &#8211; Default execution policy.<br \/>        &#8211; Permits individual commands, but scripts cannot run.<\/p>\n<p>    AllSigned<br \/>        &#8211; Scripts can run.<br \/>        &#8211; Requires a digital signature from a trusted publisher on all scripts<br \/>          and configuration files, including scripts that you write on the<br \/>          local computer.<br \/>        &#8211; Prompts you before running scripts from trusted publishers.<br \/>        &#8211; Risks running signed, but malicious, scripts.<\/p>\n<p>    RemoteSigned<br \/>        &#8211; Scripts can run.<br \/>        &#8211; Requires a digital signature from a trusted publisher on scripts and<br \/>          configuration files that are downloaded from the Internet (including<br \/>          e-mail and instant messaging programs).<br \/>        &#8211; Does not require digital signatures on scripts run from the<br \/>          local computer.<br \/>        &#8211; Does not prompt you before running scripts from trusted publishers.<br \/>        &#8211; Risks running signed, but malicious, scripts.<\/p>\n<p>    Unrestricted<br \/>        &#8211; Unsigned scripts can run.<br \/>        &#8211; Scripts and configuration files that are downloaded from the Internet<br \/>          (including Microsoft Outlook, Outlook Express and Windows Messenger)<br \/>          run after warning you that the file originated from the Internet.<br \/>        &#8211; Risks running malicious scripts.<br \/><\/span>\n\t<\/p>\n<p>Happy Scripting!\n<\/p>\n<p>Jeffrey Snover [MSFT]<br \/>Windows Management Partner Architect<br \/>Visit the Windows PowerShell Team blog at:    <a href=\"http:\/\/blogs.msdn.com\/PowerShell\">http:\/\/blogs.msdn.com\/PowerShell<\/a><br \/>Visit the Windows PowerShell ScriptCenter at:  <a href=\"http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx\">http:\/\/www.microsoft.com\/technet\/scriptcenter\/hubs\/msh.mspx<\/a>\n\t<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Over on the Microsoft.Public.Windows.PowerShell newsgroup Stefan had a number of questions about the following scenario: I want to start ps1 scripts over UNC paths or mapped network shares. I tried to change the execution policy to unrestricted but I always get the following prompt: Security WarningRun only scripts that you trust. While scripts from the [&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-7991","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-powershell"],"acf":[],"blog_post_summary":"<p>Over on the Microsoft.Public.Windows.PowerShell newsgroup Stefan had a number of questions about the following scenario: I want to start ps1 scripts over UNC paths or mapped network shares. I tried to change the execution policy to unrestricted but I always get the following prompt: Security WarningRun only scripts that you trust. While scripts from the [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/7991","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=7991"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/posts\/7991\/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=7991"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/categories?post=7991"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/powershell\/wp-json\/wp\/v2\/tags?post=7991"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}