title: Windows Defender and handling downloaded PowerShell scripts
body: <p>I use <code>Set-ExecutionPolicy RemoteSigned</code> and download some scripts and modules. These are my scripts so they are not signed. I could use <code>Bypass</code> or <code>RemoteSigned</code> or <code>Unrestricted</code>. I feel that <code>Unrestricted</code> feels a bit over the top so I got with <code>RemoteSigned</code> and indeed, even though my scripts are not signed, I can download them and run them... for a while. Then, &quot;Windows Defender&quot; catches up and completely deletes my scripts. My questions are:</p>
  <ul>
  <li><p>After I download a script, is there a <em>programmatic</em> way with PowerShell to instruct Windows Defender to mark that script on the exclusion list?</p>
  </li>
  <li><p>Would you say that <code>Unrestricted</code> is a bit unsafe? If so, what is the process of making these scripts signed (or self-signed?), or is this not possible? i.e. Set to <code>Unrestricted</code> so that files are not nuked, then download the file, then somehow put it on an exclusion list, then set the ExecutionPolicy back to <code>RemoteSigned</code>?</p>
  </li>
  </ul>