title: Converting arrays of strings to datetime
body: <p>I have a string im converting to datetime format, which works just fine:</p>
  
  <pre><code>$d = 'hourly-12-18-2017-20-15-00' -split '-'
  </code></pre>
  
  <p>Gets me:</p>
  
  <pre><code>hourly
  12
  18
  2017
  20
  15
  00
  </code></pre>
  
  <p>Converting it to datetime</p>
  
  <pre><code>$i = Get-Date -Day $d[2] -Month $d[1] -Year $d[3] -Hour $d[4] -Minute $d[5] -Second $d[6]
  </code></pre>
  
  <p>Gets me:</p>
  
  <pre><code>18. december 2017 20:15:00
  </code></pre>
  
  <p>Which is what i expect and it works.</p>
  
  <p>Now in reality this is a list of strings so im trying to loop thru it.
  The actual list after conversion:</p>
  
  <pre><code> hourly
   12
   28
   2017
   10
   15
   00
   hourly
   12
   28
   2017
   11
   15
   02
  </code></pre>
  
  <p>And so on..</p>
  
  <p>Im trying to write these out formatted:</p>
  
  <pre><code>foreach ($i in $d) {
  
  $i = @(Get-Date -Day $d[2] -Month $d[1] -Year $d[3] -Hour $d[4] -Minute $d[5] -Second $d[6])
  $i
  }
  </code></pre>
  
  <p>Gets me:</p>
  
  <pre><code>18. december 2017 20:15:00
  </code></pre>
  
  <p>Instead if the whole list. Only last entry is written out.</p>
  
  <p>I also tried with same result:</p>
  
  <pre><code>$d | ForEach-Object {
  $i = @(Get-Date -Day $d[2] -Month $d[1] -Year $d[3] -Hour $d[4] -Minute $d[5] -Second $d[6])
  }
  </code></pre>
  
  <p>Any ideas? Thanks.</p>