title: How do I populate an array of unknown length in Powershell?
body: <p>How do you work with dynamic-length arrays (ArrayLists / Lists) in Powershell? I basically want a 2D-array where the length of the outermost index is unknown. </p>
  
  <p>I tried initializing an array with <code>$array = @()</code>, but would get index out of range exceptions when addressing anything in this. Then I tried using the += operand, as I read in an article, but that would result in string concatenation and not element addition. </p>
  
  <p>Example: </p>
  
  <pre><code>$array = @()
  $array += @("Elem1x", "Elem1y")
  $array += @("Elem2x", "Elem2y")
  Echo $array[0][0]
  </code></pre>
  
  <p>Output: "E" instead of "Elem1x";</p>