Hi,
starting point is a simple powershell shell script testarray.ps1:
1 2 3 4 5 | [ CmdletBinding ()] Param ( [ Parameter ( Mandatory = $false , Position =1)][ alias ( "a" )] [string[]] $ArrayParameter =@() ) write-host "Count:" $ArrayParameter .Count |
Calling from a powershell window it is straightforward:
1 2 | PS D:\> .\testarray.ps1 -a Parameter1,Parameter2 <pre>Count:2</pre> |
But if it is called from a cmd shell it is always interpreted as a single string
1 2 | D:\> powershell.exe - file D:\testarray.ps1 -a Parameter1,Parameter2 Count:1 |
To get this working use the -Command Parameter instead of the -File parameter and set the Argument between quotation marks
1 2 | D:\> powershell.exe -Command D:\testarray.ps1 -a "Parameter1,Parameter2" Count:2 |
Michael