I've tried searching for this problem but haven't found anything helpful.
I'm trying to get a Powershell Function to loop over an array of strings. My twist is I'm trying to add a second array. The first array has the days of the week. The second array is a timestamp for example 2015-01-19
What I have working so far is below. I'm aware that using Get-Date then formatting that to what works (by adding and formatting the results) might be easier, I'm open to suggestions. -Thanks, I really do appreciate the assistance!
Function My-Test{
param(
[string[]]$arr,
[string[]]$arr2
)
Foreach($day in $arr){
"$day is the best day to read something."
}
Foreach($var2 in $arr2){
echo $arr2
}
}
$days = @("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday")
$var2 = @("1","2","3","4","5","6","7")
My-Test -arr $days -arr2 $var2
Test below
$array = @(
("Monday","Tuesday","Wednesday","Thursday","Friday","Saturday","Sunday"),
("2015-01-01","2015-01-02","2015-01-03","2015-01-04","2015-01-05","2015-01-06","2015-01-07")
)
$array[0][2]
The $array does not return the two properties, it returns Wednesday
echo $var2, you are echoing the entire array.