Powershell – cannot be loaded because running scripts is disabled on this system

Most of the times when you try to execute the PowerShell script for the first time on you machine then you will face the PowerShell Error saying “Execution of Scripts is Disabled on this System“.

Before you go ahead and execute scripts from the internet let us look into Why exactly we get this error cannot be loaded because running scripts is disabled on this system during the PowerShell Script Execution.

If you are just looking for the solution then execute the small piece of command which is provided at the end of the article.

PowerShell comes up with Security measures called as Execution Policy, this will avoid the accidental executing of the PowerShell scripts.

Measures that are taken by Default Configuration System in PowerShell

  • Avoids the execution of Scripts which is downloaded from Internet or Email
  • The code will be executed under the User Context.
  • All the Scripts must be digitally signed with a trusted digital certificate by the host system and so it will be able to execute the script.
  • It will not execute the script by double clicking on them by default.

Execution Policy and Code Signing Protections

  • Control of Execution – Control the level of trust for executing scripts.
  • Command Highjack – Prevent injection of commands in my path.
  • Identity – Is the script created and signed by a developer I trust and/or a signed with a certificate from a Certificate Authority I trust.
  • Integrity – Scripts cannot be modified by malware or malicious user

How to Check the Current Execution Policy Status on your machine?

There are basically 4 types of Execution Policy in PowerShell which is listed below.

  • Restricted – No Script either local, remote or downloaded can be executed on the system.
  • AllSigned – Only Digitally Signed Scripts can be run in the system.
  • RemoteSigned – All remote scripts (UNC) or downloaded need to be signed.
  • Unrestricted – No signature for any type of script is required.

Command to get the Current Execution Policy

Get-ExecutionPolicy

If you are getting “Restricted” after executing the above command in PowerShell then you will not be able to execute any of the Scripts.

Solution for PowerShell Error Execution of Scripts is Disabled on this System

Now you know what is causing the issue and also you have an idea on the PowerShell execution policy. All you need to do is change the execution, policy by using the Set cmdlet. Before that, there is something called as Scope which is very important to know.

Each policy stated above can be applied to different scopes which are listed below.

  • MachinePolicy: The execution policy set by a Group Policy for all users.
  • UserPolicy: The execution policy set by a Group Policy for the current user.
  • Process: The execution policy that is set for the current Windows PowerShell process.
  • CurrentUser: The execution policy that is set for the current user.
  • LocalMachine: The execution policy that is set for all users.

Change the policy to RemoteSigned and it is recommended to assign the policy to one of the scopes.

Command to Change PowerShell Execution Policy

In order to change the policy run the PowerShell in the Administrator mode and execute the below command. Execute the below command in both X86 version and the 64-bit version of PowerShell.

Enable PowerShell Scripts on Windows 7, 10, Server

Set-ExecutionPolicy RemoteSigned -Scope CurrentUser

If you would like to know the Execution Policy and Scope of all the items then execute the below command in the PowerShell window.

PowerShell Command to Get the Execution Policy List

 Get-ExecutionPolicy -List | ft -AutoSize

<# 
  Output 

  Scope ExecutionPolicy
  ----- ---------------
MachinePolicy Undefined
  UserPolicy Undefined
  Process Undefined
  CurrentUser RemoteSigned
 LocalMachine Undefined

#>
Leave a Reply

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

Sign Up for Our Newsletters

Subscribe to get notified of the latest articles. We will never spam you. Be a part of our ever-growing community.

You May Also Like