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

前端 未结 30 2362
傲寒
傲寒 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条回答
  • 2020-11-22 01:22

    Also running this command before the script also solves the issue:

    set-executionpolicy unrestricted
    
    0 讨论(0)
  • 2020-11-22 01:22

    In PowerShell 2.0, the execution policy was set to disabled by default.

    From then on, the PowerShell team has made a lot of improvements, and they are confident that users will not break things much while running scripts. So from PowerShell 4.0 onward, it is enabled by default.

    In your case, type Set-ExecutionPolicy RemoteSigned from the PowerShell console and say yes.

    0 讨论(0)
  • 2020-11-22 01:22

    Go to the registry path HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\PowerShell\1\ShellIds\Microsoft.PowerShell and set ExecutionPolicy to RemoteSigned.

    0 讨论(0)
  • 2020-11-22 01:23

    This solved my issue

    Open Windows PowerShell Command and run below query to change ExecutionPolicy

    Set-ExecutionPolicy -ExecutionPolicy RemoteSigned -Scope CurrentUser

    if it ask for confirm changes press 'Y' and hit enter.

    0 讨论(0)
  • 2020-11-22 01:24

    Setting the execution policy is environment-specific. If you are trying to execute a script from the running x86 ISE you have to use the x86 PowerShell to set the execution policy. Likewise, if you are running the 64-bit ISE you have to set the policy with the 64-bit PowerShell.

    0 讨论(0)
  • 2020-11-22 01:25
    1. Open PowerShell as Administrator and run Set-ExecutionPolicy -Scope CurrentUser
    2. Provide RemoteSigned and press Enter
    3. Run Set-ExecutionPolicy -Scope CurrentUser
    4. Provide Unrestricted and press Enter
    0 讨论(0)
提交回复
热议问题