Skip to main content

PowerShell Script Not Digitally Signed

By April 19, 2017September 16th, 2020Best Practices, Blog, Windows
PowerShell Error Message

If you’re trying to import a module or run a script and you see the following error message,

“File … cannot be loaded because running scripts is disabled on this system.”

or

“Script.ps1 is not digitally signed. The script will not execute on the system”PowerShell not signed error message

This is caused by Execution Policy; the quick fix is to run

Set-ExecutionPolicy -Scope Process -ExecutionPolicy BypassPowerShell Execution Policy Error

The command above will set the execution policy to bypass for your current PowerShell session. Once you close this PowerShell session, these settings will be lost.

Scope:

Keep in mind the -Scope parameter is setting the scope to your session. You have other scope options, and you even have the option to not set a scope at all. If the scope is not set, your settings will be kept upon exiting. For the security-minded folks out there, this can be seen as a security vulnerability. The following are the available scope options in this instance.

  • MachinePolicy
  • UserPolicy
  • Process
  • CurrentUser
  • LocalMachine

Execution Policies:

Windows PowerShell has four different execution policies:

  • Restricted– No scripts can be run. Windows PowerShell can be used only in interactive mode.
  • AllSigned– Only scripts signed by a trusted publisher can be run.
  • RemoteSigned– Downloaded scripts must be signed by a trusted publisher before they can be run.
  • Unrestricted– No restrictions; all Windows PowerShell scripts can be run.

The following links go in to far greater detail than I have and are fantastic references.

MSDN – Set-ExecutionPolicy

TechNet – Using the Set-ExecutionPolicy Cmdlet

Hey, Scripting Guy! – Can I Sign Windows PowerShell Scripts with an Enterprise Windows PKI?

Brandon Stuart, PEI

Leave a Reply