How to get rid of security warning in Batch/Powers

2019-07-21 06:25发布

问题:

I am trying to execute a powershell script via batch file and constantly getting the following warning;

-> the execution policy is set to remote signed ; i also tested with Unrestricted, the same error shows up; how to get rid of this?

回答1:

Is your ps1 script reside in a network share ? You can skip all the security process by typing set-executionpolicy bypass in a admin powershell console

or you can invoke your script by powershell.exe -executionpolicy bypass -file \\servername\share\script.ps1



回答2:

If the same error shows up, make sure you're setting the execution policy in the right place. On a 64 bit system there will be an execution policy for both 64 and 32 bit versions of Powershell. Normally, it loads the 64 bit version for the console, but uses the 32 bit version if called from a bat file. You need to launch the 32 bit version, running eleveated, and set the execution policy for it also.