PowerShell says “execution of scripts is disabled on this system.”

前端 未结 30 2814
傲寒
傲寒 2020-11-22 00:45

I am trying to run a cmd file that calls a PowerShell script from cmd.exe, but I am getting this error:

Management_Instal

30条回答
  •  萌比男神i
    2020-11-22 01:18

    We can get the status of current ExecutionPolicy by the command below:

    Get-ExecutionPolicy;
    

    By default it is Restricted. To allow the execution of PowerShell scripts we need to set this ExecutionPolicy either as Bypass or Unrestricted.

    We can set the policy for Current User as Bypass or Unrestricted by using any of the below PowerShell commands:

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Bypass -Force;
    
    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy Unrestricted -Force;
    

    Unrestricted policy loads all configuration files and runs all scripts. If you run an unsigned script that was downloaded from the Internet, you are prompted for permission before it runs.

    Whereas in Bypass policy, nothing is blocked and there are no warnings or prompts during script execution. Bypass ExecutionPolicy is more relaxed than Unrestricted.

提交回复
热议问题