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

前端 未结 30 3095
傲寒
傲寒 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:17

    I'm using Windows 10 and was unable to run any command. The only command that gave me some clues was this:

    [x64]

    1. Open C:\Windows\SysWOW64\cmd.exe [as administrator]
    2. Run the command> powershell Set-ExecutionPolicy Unrestricted

    But this didn't work. It was limited. Probably new security policies for Windows10. I had this error:

    Set-ExecutionPolicy: Windows PowerShell updated your execution policy successfully, but the setting is overridden by a policy defined at a more specific scope. Due to the override, your shell will retain its current effective execution policy of...

    So I found another way (solution):

    1. Open Run Command/Console (Win + R)
    2. Type: gpedit.msc (Group Policy Editor)
    3. Browse to Local Computer Policy -> Computer Configuration -> Administrative Templates -> Windows Components -> Windows Powershell.
    4. Enable "Turn on Script Execution"
    5. Set the policy as needed. I set mine to "Allow all scripts".

    Now open PowerShell and enjoy ;)

提交回复
热议问题