You may have to set the PowerShell execution policy when attempting to run PowerShell scripts to allow the script to run. Otherwise you may be greeted with a “scriptname cannot be loaded because running scripts is disabled on this system.” error message.
Use this tutorial to allow PowerShell script execution on your Windows system.
First, be sure that the script is not blocked from executing with these steps:
- Right-click on the icon of the script, then select “Properties“.
- Ensure the “Unblock” checkbox is selected, then select “OK“.
Option 1 – PS Command
- Select the “Start” button and type “powershell“.
- Right-click “Windows PowerShell“, then select “Run as Administrator“.
- Type the following, then press “Enter“:
Set-ExecutionPolicy RemoteSigned -Force
Option 2 – Registry Key
- Hold down the Windows Key, then press “R” to bring up the Run window.
- Type “regedit“, then select “OK“:
- Navigate to the following:
- HKEY_LOCAL_Machine
- SOFTWARE
- Microsoft
- PowerShell
- 1
- Shelllds
- Microsoft.Powershell
- Right-click the “Microsoft.PowerShell” folder, then select “New” > “String value“.
- Type “ExecutionPolicy“, then press “Enter” to set the string name.
- Open “ExecutionPolicy“, then type “RemoteSigned” in the “Value data” field.
- Select “OK“.
Option 3 – Group Policy
The settings in Group Policy to set the execution policy can be found in Group Policy Management Editor at this path:
- Policies > Administrative Templates > Windows Components > Windows PowerShell > Turn on Script Execution