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
⛔️ 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.
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 Process
Try executing the script/code now and it will work fine.
Facing issues? Have Questions? Post them here! I am happy to answer!
- PowerShell: How to Check if a Module is Already Installed
- PowerShell: How to Write Output to a File
- PowerShell: Steps to Connect to connect to Exchange Online
- PowerShell Fix: Get-Help cannot find the Help files for this cmdlet on this computer
- PowerShell Traditional For Loop Example
- How to Run PowerShell Script as Administrator (Elevate)
- Update Powershell Using Command Line
- How to delete a file using PowerShell [Windows/macOS]
- PowerShell: Grep Command Alternative - Select-String
- PowerShell Concatenate String Examples
- How to add Sleep to PowerShell Script
- Connect Azure AD (Active Directory) for PowerShell
- How to Open PowerShell on Mac?
- List of PowerShell Function Commands for Mac
- How to Connect to Azure AD Account using PowerShell on Mac
- Download Google Chrome setup exe file using PowerShell
- Set Environment Variable in PowerShell for Mac
- How to switch to Powershell on Mac Terminal
- How to add sleep in Powershell Script
- PowerShell on Mac: The term get-service is not recognized as a name of a cmdlet, function, script file, or executable program
- How to Identify installed PowerShell version
- How to check PowerShell version
- How to install PowerShell on Mac using Brew
- PowerShell Switch Statement with Examples
- PowerShell ISE Alternative for Mac
- Get FIle Size using PowerShell - Powershell
- Fix: IntelliJ No SDK for New Project - Java
- Nano Show Line Numbers - Linux
- How do I run HTML file in Notepad? (Windows) - NotepadPlusPlus
- How to Move Columns in Microsoft Excel on Mac - MacOS
- Responsive Web Design with CSS Media Queries: A Beginner's Tutorial [Updated for 2023] - CSS
- How to find someone on Instagram - HowTos