Question:
I have a .ps1 script which contains a line
1 2 |
Invoke-Expression -Command "C:\Builds\$BuildName /s /v`"/l*v c:\build_install.txt /qn`"" |
This is performing Silent installation of a product.
Now, if I try to run this command from Linux box through ssh it gives the following error:
1 2 3 4 5 6 |
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:
- Send the command through ssh or telnet
powershell.exe -Command ...
- Call the powershell Script from ssh or telnet
powershell.exe -File C:\Sample.ps1
However If I ran the same Sample.ps1
from windows Powershell, silent installation is done?
Answer:
Your /s is being interpreted as being part of your Invoke-Expression call. Can you try Invoke-Command, i.e.:
1 2 |
Invoke-Command { C:\Builds\$BuildName /s /v "/l*v c:\build_install.txt /qn" } |