When you are executing a PowerShell script for the first time you may encounter the following error:

.... cannot be loaded because running scripts is disabled on this system.

Why did this happen:

PowerShell Execution Policies

PowerShell has four execution policies for executing the script. Those four policies are described below:

Restricted

This is a default policy. If you use this policy, PowerShell won't execute any script.

Unrestricted

PowerShell will execute all scripts (local or downloaded from the Internet).

RemoteSigned

PowerShell will execute all local scripts (It will execute Internet downloaded scripts if they have a digital signature).

AllSigned

PowerShell will only run scripts which have a proper digital signature.

Solution

To resolve this issue, follow these steps:

Step 1. Open a PowerShell with elevated privileges.

Step 2. Execute the following command

Set-ExecutionPolicy RemoteSigned

Step 3. When you are prompted, press Y

Set PowerShell privileges for a script

Error when Executing a PowerShell Script for the First Time
Avatar

Karim Buzdar

About the Author: Karim Buzdar holds a degree in telecommunication engineering and holds several sysadmin certifications. As an IT engineer and technical author, he writes for various web sites. You can reach Karim on LinkedIn

One thought on “Error when Executing a PowerShell Script for the First Time

  • Avatar
    June 17, 2020 at 2:45 pm
    Permalink

    Awesome Website, a real gem of the internet.

    Reply

Leave a Reply

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

*