Tuesday, April 10, 2018

Why is Powershell blocking scripts from UNC paths?

If you are seeing errors and warnings trying to execute Powershell scripts from UNC paths on Windows 2012 and you have the IE enhanced security turned on  Powershell won't' automatically execute your scripts.

You will get a prompt like so; 'Run only scripts that you trust'.


The reason for this is that Windows treats the UNC paths as being from the internet and therefore doesn't trust anything on the UNC path

There are two solutions to this issue.

1. Add the UNC paths to the trusted sites list (either Via Regedit or GUI)
or
2. Turn off the Enhanced security
As a side note; some sites recommend using the unblock-file cmdlet but I've found that it doesn't address the issue of trusting the UNC paths.

If you find this article useful please leave me a comment.