PowerShell ps1 script is not digitally signed, you cannot run this script on the current system


If you try to run a .ps1 PowerShell script from Windows and it get an UnauthorizedAccess exception stating the PowerShell script is not digitally signed, here is quick fix. The error looks like below.

File C:\SharePointScripts\c2cInstall.ps1 cannot be loaded. The file c2cInstall.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


The Windows OS restricts execution policy by default on local system to prevent potentially harmful scripts from running that can harm the computer. This is even when running PowerShell in "Run as Administrator mode".

A common case is when you download a script from the internet and run into this error, the Windows PowerShell Execution policy safety feature controls the execution.

Here is the solution,

⛔️ unrestricted Execution Policy - Run the below command to change the execution policy and then run your script. This is an unsecured way since will allow running local and internet downloaded scripts to run and prompt for permissions to run.
Set-ExecutionPolicy -ExecutionPolicy unrestricted

✔️ bypass Execution Policy - Run the below command to temporarily bypass the execution policy and then run your script. This is a better way since it applied only to the current session and current user. During the session, nothing is blocked and no warning or prompts are displayed.
Set-ExecutionPolicy -ExecutionPolicy Bypass -Scope Process

Try executing the script/code now and it will work fine.
-


Have Questions? Post them here!


Top Hashtags: