Unable to pass array string to Powershell script

Hi, 

Since we updated our Continua to 1.7.1 (currently using 1.7.1.65), one of our powershell script which is using a parameter as array-string, started to fail. The script except an array of strings as one of its parameters like this -> [string[]]$oldVersions = (“2014.3”,“2014.4”, “2015.1”,“2015.2”)
In Continua we are calling the script with Script Arguments as -oldVersions (“2014.3”,“2014.4”, “2015.1”, “2015.2”, “2015.3”, “2015.4”)

This has been working till we updated to the latest version of continua. We now get an error in the script complaining about the value of this parameter. When I checked the log in Continua, noticed the parameter value is: 
Arguments: -NonInteractive try { [string]$pathToScript = ‘C:\CI_WS\Ws\136451\Source\Trunk\Build\Scripts\TestStage1.ps1’; [string]$arg1 = ‘(’; [string]$arg2 = ‘2014.3’; [string]$arg3 = ‘,’; [string]$arg4 = ‘2014.4’; [string]$arg5 = ‘,’; [string]$arg6 = ‘2015.1’; [string]$arg7 = ‘,’; [string]$arg8 = ‘2015.2’; [string]$arg9 = ‘,’; [string]$arg10 = ‘2015.3’; [string]$arg11 = ‘,’; [string]$arg12 = ‘2015.4’; [string]$arg13 = ')'

So it looks like the value parsing in Continua Powershell action is somehow broken. 

Regards, 
Mohsen

Hi Mohsen,

We changed the way we passed the PowerShell arguments, as another user was having issues escaping brackets. This requires that you surround your whole argument with single quotes. e.g. -oldVersions ‘(“2014.3”,“2014.4”, “2015.1”, “2015.2”, “2015.3”, “2015.4”)’ If this doesn’t work for you please post how you are reading the arguments in your script and we’ll look into what we can do to make this work.

 

Hi Dave,

I updated the parameter in Continua to be -oldVersions ‘(“2014.3”,“2014.4”, “2015.1”, “2015.2”, “2015.3”, “2015.4”)’, however with new run I got similar error, checking parameter in the build log:
Arguments: -NonInteractive try { [string]$pathToScript = ‘C:\CI_WS\Ws\136464\Source\PATrunk\Build\Source\Trunk\Build\Scripts\TestStage1.ps1’; [string]$arg1 = ‘("“2014.3"”,"“2014.4"”, "“2015.1"”, "“2015.2"”, "“2015.3"”, "“2015.4"”)’

The powershell script is like this:
Param(
[Parameter(Mandatory = $true, Position = 1, HelpMessage=“Array of the old versions”)]
[string[]]$oldVersions = (“2014.3”,“2014.4”, “2015.1”,“2015.2”)
)

foreach($oldVer in $oldVersions)
{
# Do something here
}

If I run this from powershell command line, it would work with .\TestStage1.ps1 -oldVersions = (“2014.3”,“2014.4”, “2015.1”,“2015.2”)

I tried to call the script in Continua with different format of parameter e.g. -oldVersions ‘(2014.3,2014.4,2015.1,2015.2)’ or -oldVersions (2014.3,2014.4,2015.1,2015.2) or -oldVersions 2014.3,2014.4,2015.1,2015.2 none was working.

Would you please comment?

BR,
Mohsen

Hi Mohsen,

Please download and install version 1.7.1.68 using the following links:


 Note that you will need upgrade your agents.This should deal correctly with arrays without needing the single quotes.

Hi Dave,

Thanks for the support. The package you provided, fixed the issue.

Regards,
Mohsen