Click here to Skip to main content
14,269,076 members

Running Scripts is Disabled on this System

Rate this:
2.00 (5 votes)
Please Sign up or sign in to vote.
2.00 (5 votes)
11 Sep 2018CPOL
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.”

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.

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

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)

Share

About the Author

Sunil Kumar Pashikanti
Web Developer
India India
No Biography provided

Comments and Discussions

 
-- There are no messages in this forum --
Tip/Trick
Posted 11 Sep 2018

Tagged as

Stats

3.9K views
1 bookmarked