Tuesday, December 8, 2020

PowerShell Script Cannot be Loaded because it is not Digitally Signed

Windows PowerShell Program is used to create a script or run a script in the Windows operating system. This script is used to reduce the administrative overhead. But when we try to run a script then the below error message appears.

"scriptname.ps1 cannot be loaded because it is not digitally signed"

[Replace "scriptname.ps1" as your scriptname]

Now we will discuss this issue.

Several issues are responsible for this problem. First of all we are going to check the "Set-ExecutionPolicy" rule. If your "Set-ExecutionPolicy" rule value is selected to "AllSigned" or "RemoteSigned" then that error message will appear. Because of this value, all the scripts will be checked for their digital signed. If any signed not found by a trusted publisher then that error message appears. 

To run the script on our system, we have to change the "Set-ExecutionPolicy" value to "Unrestricted". Run the below command in your PowerShell prompt:-

Set-ExecutionPolicy Unrestricted

There are four available options to work with the "Set-ExecutionPolicy" rule.

Restricted = All scripts will be disabled. No permission to run any script.
AllSigned = Only run scripts that one signed by a trusted publisher.
RemoteSigned = Scripts that are downloaded have to be signed by a trusted publisher.
Unrestricted = All scripts can be run. There are no restrictions.

Still, if you are unable to run the script please execute the below command from the PowerShell Prompt.

Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass

Still now, if you are out of luck then right-click on your script file and go to "Properties". Now click on the "Unblock" button. Also, we can use a PowerShell command to unblock one script file. The command is:-

Unblock-File -Path E:\Command\Script-run.ps1

[Please, replace the path and file name as you have.]

That's all. Now the script should be run.

No comments:

Post a Comment