Invoke-Expression: Positional parameter cannot be found that accepts argument /s

Question:

I have a .ps1 script which contains a line

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:

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

So I have also tried the following options:

  1. Send the command through ssh or telnet powershell.exe -Command ...
  2. 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.:

Source:

Invoke-Expression: Positional parameter cannot be found that accepts argument /s by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply