I want to execute an external program like so
& $exe $arguments
$arguments is string with spaces, lets say its a b c d
What happens is that the argument passed to the exe is
"a b c d"
with double quotes around the whole thing. It does not happen when $arguments contains no spaces.
How can I prevent powershell from trying to be smart and stop it from wrapping my string in double quotes? This is a ridiculous to assume that everything with spaces must be a path.
EDIT: Since a fix apparantly does not exist, I did work around by converting every bit into an array, and it does work in PS 5. However PS4 is being ****...
What I want is to have a command line argument which looks like
-filter:"+[RE*]* +[RR*]*"
PS 4 puts double quotes around the whole thing too:
$filter = "+[RE*]*", "+[RR*]*"
& $opencover -target:"$xunit" "-targetargs:$allPaths $traitsCmd -quiet -nunit xunit-$results -noshadow" -register:user -filter:"$filter" -output:opencover-$results
If I replace -filter: with '-filter:' I end up with a space between -filter: and the contents of the $filter array. Whatever I do I can't get rid of it, without wrapping the whole thing in doublequotes like "-filter:..."