How to get rid of security warning in Batch/Powershell

冷暖自知 提交于 2019-12-11 01:56:02

问题


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.



来源:https://stackoverflow.com/questions/14817141/how-to-get-rid-of-security-warning-in-batch-powershell

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!