Invoke-Expression:找不到接受参数/s的位置参数 [英] Invoke-Expression: Positional parameter cannot be found that accepts argument /s

查看:167
本文介绍了Invoke-Expression:找不到接受参数/s的位置参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.ps1脚本,其中包含一行

I have a .ps1 script which contains a line

Invoke-Expression -Command "C:\Builds\$BuildName /s /v`"/l*v c:\build_install.txt /qn`""<br/>

这正在执行产品的静默安装.

This is performing Silent installation of a product.

现在,如果我尝试通过ssh在Linux操作系统中运行此命令,则会出现以下错误:

Now, if I try to run this command from Linux box through ssh it gives the following error:

Invoke-Expression : A positional parameter cannot be found that accepts argument '/s'.
At line:1 char:1
+ Invoke-Expression C:\NWTBuilds\Setup-NimbleNWT-x64.2.0.4.117.exe /s /v`/l*v c:\n ...
+ CategoryInfo          : InvalidArgument: (:) [Invoke-Expression], ParameterBindingException
+ FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.InvokeExpressionCommand

您对此有何建议?我需要提供任何凭证吗?

Do you have any suggestions on this? Do I need to provide any credentials?

所以我也尝试了以下选项:

So I have also tried the following options:

  1. 通过ssh或telnet发送命令 powershell.exe -Command ...
  2. 从ssh或telnet调用powershell脚本 powershell.exe-文件C:\ Sample.ps1

但是,如果我从Windows Powershell中运行了相同的 Sample.ps1 ,是否完成了静默安装?

However If I ran the same Sample.ps1 from windows Powershell, silent installation is done?

推荐答案

您的/s 被解释为您的 Invoke-Expression 调用的一部分.您可以尝试 Invoke-Command ,即:

Your /s is being interpreted as being part of your Invoke-Expression call. Can you try Invoke-Command, i.e.:

Invoke-Command { C:\Builds\$BuildName /s /v "/l*v c:\build_install.txt /qn" }

这篇关于Invoke-Expression:找不到接受参数/s的位置参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆