![](/img/trans.png)
[英]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.