When trying to pass agent paths (via query syntax) that contain 'Program Files (x86)' to powershell scripts, I receive the following error:
x86 : The term 'x86' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
It turns out this is because the brackets surrounding x86 are not escaped. To reproduce, I used the following arguments in a powershell action as script arguments, resulting in the error above.
-badarg '$Agent.MSBuild.12.0.PathX86$'
This expanded to:
When it should probably be escaping the brackets with back ticks?
-badarg 'C:\Program Files `(x86`)\MSBuild\12.0\bin\'
If I enter the path manually (without variable expansion) and use the back-ticks, it works as expected.