[英]execution policy error while calling powershell script from batch file, powershell v 1.0
[英]error in execution policy using powershell version 1.0
IAM使用以下命令在服务器上以静默方式安装Service Pack
H:\>powershell.exe -executionpolicy bypass -noninteractive -nologo -file path\SP_Ins
tallation.ps1 ax-riscvmsql68\sql68 d:\sysdba\SQLServer2008SP4-KB2979596-x64-E
NU.exe 2>&1
IAM在PowerShell版本4.0上运行此命令时未收到任何错误
当iam在1.0版上运行相同命令时,出现以下错误
H:\>powershell.exe -executionpolicy bypass -noninteractive -nologo -file path\SP_Installation.ps1 ax-riscvmsql68\sql68 d:\sysdba\SQLServer2008SP4-KB2979596-x64-ENU.exe 2>&1
Missing expression after unary operator '-'.
At line:1 char:2
+ -e <<<< xecutionpolicy bypass -noninteractive -nologo -file path\SP_Installation.ps1 ax-riscvmsql68\sql68 d:\sysdba\SQLServer2008SP4-KB2979596-x64-ENU.exe
您能帮我个忙吗,因为Powershell 1.0版无法识别执行策略
根据这篇文章
你只能使用restricted
, remotesigned
, Allsigned
,并且unrestricted
在PowerShell中V1.0。
受限制的
不要加载配置文件或运行脚本。 这是默认值。
全部签名
要求所有脚本和配置文件均由受信任的发布者签名,包括您在本地计算机上编写的脚本。
远程签名
要求从Internet下载的所有脚本和配置文件均由受信任的发布者签名。
无限制
加载所有配置文件并运行所有脚本。 如果运行从Internet下载的未签名脚本,则会在运行之前提示您获得许可。
正如@Ansgar Wiechers所说,请远离v1.0 ...这已经过时了,大多数系统都使用v3.0及更高版本。 v1.0中的某些命令和属性比其他更新版本不可用。
因此,这是解决方案,您无法使用Powershell 1.0版,因为执行策略主机需要在Powershell 2.0版以上
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.