Powershell: A Local script is not executed with error not digitally signed


Issue: You downloaded or copied a script from a remote location and Powershell won’t execute such a file although you have set the execution policy to RemoteSigned.

An Error like this occurs:

D:\Temp\myScript.ps1 : File D:\Temp\myScript.ps1 cannot
be loaded. The file D:\Temp\myScript.ps1 is not digitally signed. The script
will not execute on the system.

Reason for this is that a alternate datastream with a Zone.Identifier is added to a file which identifies that the file is fetched from a remote location.

Powershell provides an command let to remove such information. Call Unblock-File

PS D:\> unblock-file D:\Temp\myScript.ps1

and it is executed as expected


Advertisment to support michlstechblog.info

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.