If you’ve ever tried to run a PowerShell script and encountered the error message “The file is not digitally signed. You cannot run this script on the current system”, you’re not alone. This is a common issue that many PowerShell users face, but fortunately, it’s relatively easy to fix.
The File Is Not Digitally Signed; Why Does This Error Occur?
The “not digitally signed” error occurs because of PowerShell’s execution policy settings. By default, PowerShell is configured to only allow signed scripts to run. This is a security measure to prevent unauthorized or malicious scripts from executing on your system.
When you try to run a script that isn’t digitally signed, PowerShell blocks it and displays the error message. This can be frustrating, especially if you know the script is safe and you wrote it yourself.
The File Is Not Digitally Signed You Cannot Run This Script: How to Fix?
There are two main ways to resolve this error:
- Sign your PowerShell scripts: You can digitally sign your scripts using a code signing certificate. This proves the script’s authenticity and allows it to run without changing the execution policy. However, obtaining a code signing certificate can be a bit involved.
- Change the PowerShell execution policy: The easier solution is to modify PowerShell’s execution policy to allow unsigned scripts to run. You can do this using the
Set-ExecutionPolicycmdlet. Changing the execution policy to “RemoteSigned” is usually a good choice as it allows locally created scripts to run while still requiring remote scripts to be signed.
To change the execution policy, open PowerShell as an administrator and run:
Set-ExecutionPolicy RemoteSignedConfirm the change by typing “Y” when prompted.
After changing the execution policy, you should be able to run your unsigned local scripts without encountering the “not digitally signed” error.
A Word of Caution
While modifying the execution policy is a quick fix, it’s important to understand the security implications. Running unsigned scripts can be risky, as they could potentially contain malicious code. Always ensure you trust the source of a script before running it, even if you’ve set the execution policy to allow unsigned scripts.
If you’re in an enterprise environment, be aware that group policies may restrict your ability to change the execution policy. In such cases, you’ll need to work with your IT department to find a solution that aligns with your organization’s security policies.
Conclusion
In this tutorial, I have explained how to fix the error: the file is not digitally signed. you cannot run this script on the current system in PowerShell. By either signing your scripts or adjusting the execution policy, you can get your scripts running smoothly. Do let me know in the comment below if it fixed your issue.
You may also like:
- Run PowerShell Script From Command Line With Parameters
- PowerShell Naming Conventions & Best Practices
- PowerShell Where-Object
- PowerShell Where-Object vs Filter
Bijay Kumar is an esteemed author and the mind behind PowerShellFAQs.com, where he shares his extensive knowledge and expertise in PowerShell, with a particular focus on SharePoint projects. Recognized for his contributions to the tech community, Bijay has been honored with the prestigious Microsoft MVP award. With over 15 years of experience in the software industry, he has a rich professional background, having worked with industry giants such as HP and TCS. His insights and guidance have made him a respected figure in the world of software development and administration. Read more.