I have a script that require 2 arrays as input, and optional logname :
#file:test.ps1
Param(
[string[]]$array1,
[string[]]$array2,
[string]$logName = "log{0}.csv" -f (get-date -format "yyyyMMdd")
)
"array1: {0}" -f ($array1 -join " ")
"array2: {0}({1})" -f ($array2 -join " ") ,$array2.count
"logName: {0}" -f $logName
When run from a PowerShell console, everything is fine:
PS D:\temp> .\test.ps1 -array1 one,two -array2 1,2,3 array1: one two array2: 1 2 3(3) logName: log20190723.csv
But when run by calling powershell.exe
(for scheduled task), only first element from array is grabbed, the rest is passed to the logname parameter.
PS D:\temp> powershell.exe -F D:\temp\test.ps1 -array1 one,two -array2 1,2,3 array1: one array2: 1(1) logName: two
How should I define params to grab all params into the array?
(BTW: I'm using PS4.0, with same result on Windows 2008 and 2012)