1

[Could not find any relevant nor working answer, I checked the parameters, they are legit]

I try to run an executable with its respective parameters, but with powershell

here is the line:

Invoke-Command -FilePath "$execPath\xxxxxxxxxxxxxx.exe" -ArgumentList '--param1','param2'

and here is the error

Invoke-Command : Parameter set cannot be resolved using the specified named parameters.
At xxxxxxxx.ps1:18 char:5
+     Invoke-Command -FilePath "$execPath\xxxxxxxxxxxxxx.exe" -Argument ...
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [Invoke-Command], ParameterBindingException
    + FullyQualifiedErrorId : AmbiguousParameterSet,Microsoft.PowerShell.Commands.InvokeCommandCommand

thanks for enlighting me on this one

1 Answers1

1

I got it working like this

& "$execPath\xxxxxxxxxxxxxx.exe" "param1" "param2"
  • Indeed, that's the best solution - use of `Invoke-Command` for _local_ calls is rarely needed. `-FilePath` can (a) only be used in _remote_ calls and (b) only with a _script_ file path (`*.ps1`), not executables in general; such calls require use of a _script block_ (`{ ... }`) instead. See the liked duplicate for details. – mklement0 Jun 15 '23 at 16:43