I have a snippet of Powershell where I need to call an external executable, with a list of switches.
& $pathToExe
--project $project `
--server $server `
--apiKey $key `
Now I need to do something like "if $someVariable -eq $True then also add --optionalSwitch $someValue".
How can I do this without a load of repetition? For reference the real exe call is much bigger than this, and the list of optional switches is larger!
--project:$project --server:$server(:rather than spaces between switches and arguments) - if so, it's trivial with splatting--debug. Would your suggestion still work for those?