What does the error "Script execution disabled on this system" mean?

Asked

Viewed 109,646 times

45

I was testing some things from PowerShell ISE so you can build some scripts.

I realized that while I was running the script without saving the file, the commands were executed normally. However, soon after saving the file on the desktop, the execution of it started generating the following error:

The archive script.ps1 cannot be loaded because the script execution has been disabled on this system.

See "get-help about_si gning" for more details. At line:0 char:0

But I didn’t disable anything...

What "enabling" is Windows talking about? How can I enable Powershell script execution on Windows?

6 answers

73


This is a Powershell security policy to prevent scripts malicious to be improperly executed on your system. Therefore, all scripts which are not signed will have their execution blocked. That is, the execution policy is as Restricted (which is the standard).

You can control these permissions using the cmdlet Set-ExecutionPolicy. And you can check the current execution policy using the cmdlet Get-ExecutionPolicy.

PS C:\Users\LINQ> Get-ExecutionPolicy
Restricted

PS C:\Users\LINQ> Set-ExecutionPolicy RemoteSigned
PS C:\Users\LINQ> Get-ExecutionPolicy
RemoteSigned

There are several types of permission you can use with this cmdlet

Restricted

Does not load or execute configuration files and/or scripts powershell.

Allsigned

Only executes scripts and configuration files signed by a trusted vendor, even if the script has been written by yourself (local).

Remotesigned

It is basically the same as the above, but allows the execution of configuration files and/or scripts local.

Unrestricted

Loads and executes all configuration files and scripts Powershell. A confirmation can be requested to run scripts unsigned.

Bypass

There is no restriction.

Undefined

Removes the current execution policy. Unless it is defined in a group directive.

18

By default the privilege to excommunicate scripts is the Restricted, ie, no script called via file can be run only in interactive mode (via console or ISE)

To change the execution policy use cmdlet and any of the following

Set-ExecutionPolicy AllSigned 

Restricted: It is default value (Windows 8, Windows Server 2012, and Windows 8.1) , does not allow any file to run that includes configuration files (.ps1xml), modules (.psm1) and . ps1

AllSigned: Allows file execution, but requires files to be signed by a trusted publisher.

Unrestricted: Unsigned scripts can run.

Bypass: Nothing is blocked and does not send warnings or prompts (asks if you want to run something for example)

Undefined: Sets the undefined execution policy. If all scopes are Undefined by default she turns Restricted. You can check the different levels with:

Get-ExecutionPolicy -list

Recommended reading:

Set-Executionpolicy

About Execution Policies

4

It is also possible to change values via registry key (regedit or command reg in the cmd):

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell]
"ExecutionPolicy"="bypass"

Save the lines above as liberar.reg, and open, or use the command reg import liberar.reg

  • 1

    Constructive criticism: What "bypass" does?

3

An alternative to fix the problem is to run the command below inside the Command Prompt

Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

In my case I was happening when I tried to execute the command ng s to start the Angular application.

Running the above command no longer shows the problem!

-1

Using powershell(ADM) can you change the terminal Configuration with this command:

IN powerShell(ADM)
1(Set-ExecutionPolicy -ExecutionPolicy Bypass)
2(select "Yes For All (A)")

-4

Open Windows Power Shell prompt as administrator.

Execute the command: Set-Executionpolicy Unrestricted

  • The question is "What does the "Script execution has been disabled on this system" error mean?" , this is an answer field that you used and not comment, if you do not answer the question then it is not an answer. We are not a forum, we are a site of QUESTIONS and ANSWERS definitive or complementary, but they should always be explained.

  • ok, the intention was only to help... because I’ve been through the same problem... Note the last question asked: "How can I activate the execution of Powershell scripts in Windows?" abcs!!!

  • 2

    I say again what I always say to those who are starting on the site, we are not a forum and this field "publish your answer" is to solve the question problem and not to comment on things, if it doesn’t solve completely or it’s not a complement to someone else’s answer then it’s not the place you should use, imagine someone coming to your house or your new company, not reading the rules and starting to mess everything up, so that’s it, read the rules, we are a good community and understand how it works to participate is to respect the community. Welcome back to Marlon.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.