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

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


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" }


The error message indicates that PowerShell is trying to parse /s as the name of a parameter of Invoke-Expression rather than as part of the argument supplied to -Command, which it would not do if the /s were part of the string. This implies that the string is being terminated just before that. Check the value of $BuildName, it probably contains something that terminates the string. I'm not quite sure what that might be, because a pair of double quotes within the variable value shouldn't have that effect. At least it wouldn't at a PowerShell prompt. Maybe the ssh client is interpreting what you're typing in some way that terminates the string before /s?

In any case, I'd be willing to bet money that the answer lies in the value of $BuildName, because logically the error indicates that the string argument to -Command terminates at that point.