I use Set-ExecutionPolicy RemoteSigned
and download some scripts and modules. These are my scripts so they are not signed. I could use Bypass
or RemoteSigned
or Unrestricted
. I feel that Unrestricted
feels a bit over the top so I got with RemoteSigned
and indeed, even though my scripts are not signed, I can download them and run them... for a while. Then, "Windows Defender" catches up and completely deletes my scripts. My questions are:
After I download a script, is there a programmatic way with PowerShell to instruct Windows Defender to mark that script on the exclusion list?
Would you say that
Unrestricted
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 toUnrestricted
so that files are not nuked, then download the file, then somehow put it on an exclusion list, then set the ExecutionPolicy back toRemoteSigned
?
Downloaded files are marked as from the internet. Your need to unblock them. Use the built-in cmdlet for that.
Any script you use will be looked at for actions it is performing. Your AV solution (Windows Defender notwithstanding) will take action(s) on it if it appears to be doing unexpected/nefarious things at any point. This has nothing to do with whether they are signed or not, or what ExecutionPolicy you set.
EP = only means allow a script(s) to run, not control what the script does/is going to do and the EP is not a security boundary, as documented in the help files.
This is all related to Windows ADS.
Downloaded file via zone 3, we now know that is the Internet Zone as depicted in the chart below.
Or using MS SysInternals: streams.exe