<p>Since this question continues to attract responses that are either<br>
refuted by the question body or don’t address the actual problem,<br>
<strong>please read this simple summary</strong> of what you need to know:</p>
<ul>
<li>
<p><strong>This is <em>not</em> a "Why won’t my default installation of PowerShell run scripts?" question.</strong></p>
</li>
<li>
<p><strong>This is <em>not</em> a "Why won’t my installation of PowerShell run scripts downloaded from the internet?" question.</strong></p>
</li>
<li>
<p><strong>The question is why the <code>RemoteSigned</code> execution policy is preventing script execution when it shouldn’t.</strong></p>
</li>
<li>
<p><strong><code>RemoteSigned</code> is the <em>only</em> execution policy I want to use.</strong> I am aware that other, less-restrictive policies are available. If<br>
those policies were acceptable substitutes I would have just used them<br>
instead and this question wouldn’t exist.</p>
</li>
<li>
<p><strong>The execution policy is <em>already</em> set to <code>RemoteSigned</code>.</strong> Changing it from <code>RemoteSigned</code> to <code>RemoteSigned</code> is not a solution.</p>
</li>
<li>
<p><strong>The script file is created and stored locally.</strong></p>
</li>
<li>
<p><strong>The script file is not blocked.</strong> The script file was never blocked (see previous point).</p>
</li>
<li>
<p><strong>The script file cannot be unblocked</strong> because there is nothing to unblock (see previous point).</p>
</li>
<li>
<p><strong>The script file is (attempted to be) executed by an administrator.</strong></p>
</li>
<li>
<p><strong>Windows PowerShell is the only application involved.</strong> Not Windows PowerShell ISE nor Command Prompt nor any other tools or<br>
editors are relevant.</p>
</li>
<li>
<p><strong>The cause of the problem has <em>already</em> been identified</strong> (see accepted answer). After nearly 8 years, I think all other obvious<br>
explanations, whether applicable or not, have been posted, too. If<br>
you think otherwise then <strong>please read the question and existing<br>
answers <em>in their entirety</em> before adding yours.</strong></p>
</li>
</ul>
<p>I am using Windows PowerShell 2.0 on 64-bit Windows 7 Professional. I have a script on my desktop that causes the following error when I try to run it:</p>
<pre><code class="lang-auto">File C:\Users\UserName\Desktop\Script.ps1 cannot be loaded. The file C:\Users\UserName\Desktop\Script.ps1 is not digitally signed. The script will not execute on the system. Please see "get-help about_signing" for more details..
At line:1 char:54
- C:\Users\UserName\Desktop\TestGetWindowsUpdateLog.ps1 <<<<
- CategoryInfo : NotSpecified: (🙂 [], PSSecurityException
- FullyQualifiedErrorId : RuntimeException
</code></pre>
<p>I am both a domain administrator and a local administrator, and if I run <code>Get-ExecutionPolicy -List</code>, I can see that the Group Policy Object I created to configure PowerShell is correctly applying the <code>RemoteSigned</code> execution policy at the machine level:</p>
<pre><code class="lang-auto"> Scope ExecutionPolicy
MachinePolicy RemoteSigned
UserPolicy Undefined
Process Undefined
CurrentUser Undefined
LocalMachine Undefined
</code></pre>
<p>I created the script myself in Notepad, and used the <a href="https://www.sysinternals.com/" rel="noopener nofollow ugc">Sysinternals</a>’ <a href="https://learn.microsoft.com/sysinternals/downloads/streams" rel="noopener nofollow ugc">Streams</a> utility and the File Properties dialog to confirm that the script is not being treated as having come from the internet. If I copy the script to a network share on a domain server, then it’s allowed to execute. If I run <code>Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope LocalMachine</code> then the local script is still not allowed to execute, which makes sense since the execution policy at the <code>MachinePolicy</code> scope will take precedence.</p>
<p>As documented by <code>about_Execution_Policies</code>(<a href="https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_execution_policies" rel="noopener nofollow ugc">current</a>; <a href="https://technet.microsoft.com/library/dd347641.aspx" rel="noopener nofollow ugc">at time of question</a>), the <code>RemoteSigned</code> policy means:</p>
<ul>
<li></li>
</ul>
<p>Scripts can run.</p>
<ul>
<li></li>
</ul>
<p>Requires a digital signature from a trusted publisher on scripts and configuration files that are downloaded from the Internet<br>
(including e-mail and instant messaging programs).</p>
<ul>
<li></li>
</ul>
<p>Does not require digital signatures on scripts that you have run and that you have written on the local computer (not downloaded from<br>
the Internet).</p>
<ul>
<li></li>
</ul>
<p>Risks running unsigned scripts from sources other than the Internet and signed, but malicious, scripts.</p>
<p>My script is not signed, but since it is both created and executed locally, it should satisfy the third bullet point above. Therefore…</p>
<ul>
<li>
<p>Why is my script not being allowed to run?</p>
</li>
<li>
<p>Why does PowerShell complain that my script "is not digitally signed" when that requirement should only apply to files from the Internet?</p>
</li>
<li>
<p>Why does PowerShell no longer care about the script not being signed when it’s run from a network share?</p>
</li>
</ul>
<hr>
<p><em>Source : <a href="https://www.sysinternals.com/" rel="noopener nofollow ugc">Stack Overflow</a>’)</em></p>