Powershell: Security Error – Not digitally signed. You cannot run this script on the current system

PowerShell is built on the .NET Framework. It shares some syntax features and keywords with the C# programming language. Learning PowerShell can make it much easier to learn C#. If you’re already familiar with C#, these similarities can make learning PowerShell easier. However if you are not familiar with either, running a simple Powershell command that you downloaded from the internet can be problematic. If you think you don’t need to know Powershell think again, because it is pretty much a must have skill to do even basic Administration in Microsoft Azure.

By default, PowerShell is configured to run under a Restricted execution policy. This execution policy is the most secure, which means no scripts can be run, and only configuration files digitally signed by a trusted publisher are allowed to run or load. If you’ve downloaded a Powershell PS1 file from the internet you are very likely to have come across an error along the lines of …”Not digitally signed. You cannot run this script on the current system”.

If you trust the source of your script, try using the unblock-file command before you run e.g.

Unblock-File -Path C:\Working\Moodle-AzureAD-Powershell\Moodle-AzureAD-Script.ps1

Then run your script:

.\Moodle-AzureAD-Script.ps1

Alternatively, you can open the extracted folder that contains your Powershell PS1 file and do the following.
* Right-click on your `.ps1` file and select *Properties*.
* Under the *General* tab of the Properties window, check the `Unblock` box next to the *Security* attribute at the bottom.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.