简体   繁体   中英

error in execution policy using powershell version 1.0

Iam using following command for silent installation of service pack on servers

 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 not getting any error while running this command on powershell version4.0

when iam running same command on version 1.0 it gives me following error

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

can you please help me out as execution policy is not recognized in powershell version 1.0

According to this article

You can only use restricted , remotesigned , Allsigned , and unrestricted in Powershell v1.0.

  • Restricted

    Do not load configuration files or run scripts. This is the default.

  • AllSigned

    Require that all scripts and configuration files be signed by a trusted publisher, including scripts that you write on the loca l computer.

  • RemoteSigned

    Require that all scripts and configuration files downloaded from the Internet be signed by a trusted publisher.

  • Unrestricted

    Load all configuration files and run all scripts. If you run an unsigned script that was downloaded from the internet, you are prompted for permission before it runs.

As @Ansgar Wiechers said please move away from v1.0... It is extremely outdated and most systems use v3.0 and above. Some commands and properties are not available in v1.0 than other updated versions.

因此,这是解决方案,您无法使用Powershell 1.0版,因为执行策略主机需要在Powershell 2.0版以上

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM