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,
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 ProcessTry executing the script/code now and it will work fine.
Provide Feedback For This Article
We take your feedback seriously and use it to improve our content. Thank you for helping us serve you better!
😊 Thanks for your time, your feedback has been registered!
Comments & Discussion
Facing issues? Have questions? Post them here! We're happy to help!