[1.7.0.108] Powerhsell action does not escape brackets in expanded variable arguments

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:

-badarg 'C:\Program Files (x86)\MSBuild\12.0\bin\'

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.

Hi Joel

The issue here is that the variable expansion is done by code that knows nothing about powershell. We’ll have to have a think about what can be done here.

Confirming as fixed in 1.7.1 - also had to change all quotes to single quotes in the argument parameters, but after that it all worked well. The action is a LOT easier to use now! Cheers for the fast solution.