Powershell – enable execution scripts

I was writing a powershell script to get some system information and got an error saying “cannot be loaded because the execution of scripts is disabled on this system.”

To check the policy set up you can run
Get-ExecutionPolicy

There are four different execution policy and this will return one of the below:

Restricted (No scripts can be run. Windows PowerShell can be used only in interactive mode)
AllSigned (Only scripts signed by a trusted publisher can be run)
RemoteSigned (Downloaded scripts must be signed by a trusted publisher before they can be run.)
Unrestricted (No restrictions; all Windows PowerShell scripts can be run.)

So now to enable the execution policy run the below command: (i’m using the RemoteSigned)
Set-ExecutionPolicy RemoteSigned

Powershell - after execution enabled

There are also other ways to do this but the above is just one method.

 

using regedit:

powershell regedit