[Solved] Problems passing "arrays" to Powershell
Posted: 21 Apr 2013 00:33
Hi,
I got some headaches trying to pass an array of values from XY to Powershell.
When I run the PS-script "test.ps1" (attached, just remove the fake zip-extension) from the console everything works as expected and I got output 2 values passed.
When I try to run the same script from XY something gets scrambled though the command string seems to be ok.Note the double quotes around the passed dirs don't differ from the ones given when running the script straight from the console.
But now the console output has changed, something not obvious must be different.
Here is the script code (just put testRunPS.xys into the same folder as the PS-script):
Where am I wrong?
Thanks & cheers,
Filehero
I got some headaches trying to pass an array of values from XY to Powershell.
When I run the PS-script "test.ps1" (attached, just remove the fake zip-extension) from the console everything works as expected and I got output 2 values passed.
Code: Select all
PS $> .\test.ps1 -dirs "Folder 1", "Folder 2"
The number of dirs passed in dirs is: 2
1: Folder 1
2: Folder 2But now the console output has changed, something not obvious must be different.
Code: Select all
The number of dirs passed in dirs is: 1
1: Folder_1,Code: Select all
$scriptPath = self("path");
$cmd = "Powershell -NoExit -File ""$scriptPath\test.ps1"" -dirs ""Folder_1"", ""Folder_2""";
msg($cmd);
run($cmd);Thanks & cheers,
Filehero