Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / PowerShell

Running Scripts is Disabled on this System

2.00/5 (5 votes)
11 Sep 2018CPOL1 min read 6.9K  
Running scripts is disabled on this system

When we try to run the powershell script on the Windows PowerShell or Sharegate PowerShell, we might come across the below error:

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

Image 1

WINDOWS POWERSHELL EXECUTION POLICIES prevents running of all script files, including:

  • formatting and configuration files (.ps1xml),
  • module script files (.psm1), and
  • Windows PowerShell profiles (.ps1)

Use the below command to get the Execution Policies, it gives the policies list and its scope.

Get-ExecutionPolicy –List

Here, we can see that all policies are set to undefined, if the execution policy in all scopes is Undefined, the effective execution policy is Restricted, which is the default execution policy.

Image 2

That is the reason we are not able to run the scripts. To enable, we have to modify/set the execution policy, for this, use the below command:

Set-ExecutionPolicy unrestricted

This command removes the restriction policy for the Local Machine scope. It gives a prompt message, click on OK to accept the changes in policy. We have successfully modified the restriction policy.
Now, check the policies by using the below command:

Get-ExecutionPolicy –List

Image 3

You can see that the Local Machine scoped execution policy has changed to “Unrestricted”. Even you can see that we were able to run the PowerShell command without any problems.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)