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

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

    You can bypass this policy for a single file by adding -ExecutionPolicy Bypass when running PowerShell

    powershell -ExecutionPolicy Bypass -File script.ps1
    
    0 讨论(0)
  • 2020-11-22 01:27
    1. Open powershell as administration
    Set-ExecutionPolicy -Scope "CurrentUser" -ExecutionPolicy "RemoteSigned"
    

    use this command

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

    Now run the run command what ever you are using.. Trust this the app will runs.. Enjoy :)

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

    I get another warning when I tryit to run Set-ExecutionPolicy RemoteSigned

    I solved with this commands

    Set-ExecutionPolicy "RemoteSigned" -Scope Process -Confirm:$false
    
    Set-ExecutionPolicy "RemoteSigned" -Scope CurrentUser -Confirm:$false
    
    0 讨论(0)
  • 2020-11-22 01:27

    You can use a special way to bypass it:

    Get-Content "PS1scriptfullpath.ps1" | Powershell-NoProfile -
    

    It pipes the content of powershell script to powershell.exe and executes it bypassing the execution policy.

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

    you may try this and select "All" Option

    Set-ExecutionPolicy -Scope CurrentUser -ExecutionPolicy RemoteSigned
    
    0 讨论(0)
提交回复
热议问题