title: Slice a PowerShell array into groups of smaller arrays
body: <p>I would like to convert a single array into a group of smaller arrays, based on a variable.  So, <code>0,1,2,3,4,5,6,7,8,9</code> would become <code>0,1,2</code>,<code>3,4,5</code>,<code>6,7,8</code>,<code>9</code> when the size is 3.</p>
  
  <p>My current approach:</p>
  
  <pre><code>$ids=@(0,1,2,3,4,5,6,7,8,9)
  $size=3
  
  0..[math]::Round($ids.count/$size) | % { 
  
      # slice first elements
      $x = $ids[0..($size-1)]
  
      # redefine array w/ remaining values
      $ids = $ids[$size..$ids.Length]
  
      # return elements (as an array, which isn't happening)
      $x
  
  } | % { "IDS: $($_ -Join ",")" }
  </code></pre>
  
  <p>Produces:</p>
  
  <pre><code>IDS: 0
  IDS: 1
  IDS: 2
  IDS: 3
  IDS: 4
  IDS: 5
  IDS: 6
  IDS: 7
  IDS: 8
  IDS: 9
  </code></pre>
  
  <p>I would like it to be:</p>
  
  <pre><code>IDS: 0,1,2
  IDS: 3,4,5
  IDS: 6,7,8
  IDS: 9
  </code></pre>
  
  <p>What am I missing?</p>