I'm trying to build up a multi-dimensional array in PowerShell programmatically using CSV files located on disk. I have been importing the array into a temporary variable and then appending the array to the array. Instead of an array of arrays I get a single array with the total number of rows. I worked it out with smaller arrays and found the following:
$array1 = "11","12","13"
$array2 = "21","22","23"
$array3 = "31","32","33"
$arrayAll = $array1, $array2, $array3
$arrayAll.Count # returns 3
$arrayAll = @();
$arrayAll += $array1
$arrayAll += $array2
$arrayAll += $array3
$arrayAll.count # returns 9
The first method for building the array works but I need to be able to use the second method. How do I fix this?