How to fix PowerShell script error: "The script is not digitally signed. You cannot run this script on the current system."
Every now and then, when I attempt to run a PowerShell script, I encounter the following error. This error prevents me from running the scripts necessary for tasks such as setting up a local development environment.
PowerShell script error
.\node-environment-setup.ps1 : File
D:\git\repos\ProjectName\Website\ProjectName.Shared.Frontend\build_utilities\node-environment-setup.ps1 cannot be loaded. The
file D:\git\repos\ProjectName\Website\ProjectName.Shared.Frontend\build_utilities\node-environment-setup.ps1 is not digitally
signed. You cannot run this script on the current system. For more information about running scripts and setting
execution policy, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170.
At line:1 char:1
+ .\node-environment-setup.ps1
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : SecurityError: (:) [], PSSecurityException
+ FullyQualifiedErrorId : UnauthorizedAccess
A quick fix: Updating the ExecutionPolicy of the Process Scope
Below are the four steps to fix this error:
- Run Windows PowerShell as an Administrator.
- Run your PowerShell script and see the error mentioned above.
- Run Get-ExecutionPolicy -List command to display the execution policies for each scope in the order of precedence. See that Process scope's ExecutionPolicy is set to Undefined.
- Run Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass command to update the ExecutionPolicy of Process scope to Bypass. Type A to select the "Yes to All" option.
- Run Get-ExecutionPolicy -List command again to check that the Process scope's ExecutionPolicy is set to Bypass.
- Run your PowerShell script again, you shouldn't see the same error message again.
- Once you're done with running your script, set the Process scope's ExecutionPolicy to back to Undefined again by running this command: Set-ExecutionPolicy -Scope Process -ExecutionPolicy Undefined
Comments
Post a Comment