PowerShell is pretty powerful tool and as Peter Parker will tell you; with great power comes great responsibility. This powerful tool can be used to harm your system if you aren’t careful how you use it. Specifically, harmful PowerShell scripts, if allowed to run, can break something. This is precisely why PowerShell restricts running scripts. It has several layers of security that can be applied which restrict all scripts or just unsigned and unverified scripts. If you’re unable to run a PowerShell script that you are sure is safe, then you need to change the PowerShell execution policy in order to do so. Here’s how.
Login to your system with the Administrator account and open PowerShell with administrative rights.
Run the following command;
PowerShell will ask you for a parameter. The parameter tells you what permissions to set for PowerShell.
There are four parameters that you can set;
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.
Enter the parameter that corresponds to the permissions you want to set and tap Enter.
You will be asked to confirm the change before it is executed. Type the corresponding letter to confirm the change and tap Enter.
The change takes place on the fly. You won’t have to restart your system or PowerShell. If you were previously unable to run a PowerShell script, you can give PowerShell the path to it now and it will run.
Reversing the change is simple and follows this same process. You must run the Set-ExecutionPolicy command and then supply the parameter of your choice. If previously you gave PowerShell unrestricted access, you can restrict it or limit it once again with the correct parameter.
This is how you change the PowerShell execution policy on all versions of Windows.