How do you successfully change execution policy and enable execution of PowerShell scripts

前端 未结 7 1522
情话喂你
情话喂你 2020-12-02 12:04

I have a problem regarding changing the Execution Policy in my Windows Server 2008+ OS. It is the first time I try to run a script for which I need resource full ac

7条回答
  •  一整个雨季
    2020-12-02 12:48

    Add the following to a file named psa.cmd and put in a folder included your PATH :

    POWERSHELL -Command "$enccmd=[Convert]::ToBase64String([System.Text.Encoding]::Unicode.GetBytes((Get-Content '%1' | Out-String)));POWERSHELL -EncodedCommand $enccmd"
    

    Now you can run any powershell script as in:

    psa script.ps1
    

提交回复
热议问题