title: Loop through dates in hash table?
body: <p>I have a hash table in Powershell that looks like this (<code>$hash_dates.GetEnumerator() | sort -Property name</code>):</p>
  
  <pre><code>11/1/2016 12:00:00 AM          5
  11/2/2016 12:00:00 AM          3
  11/4/2016 12:00:00 AM          2
  </code></pre>
  
  <p>The key is of type DateTime.</p>
  
  <p>I am running a for loop to catch all the dates (dates only, times don't matter thus all midnight) and pull out each value in the hash table based on the date. The code:</p>
  
  <pre><code>$startdate = (get-date).AddDays(-30)
  $today = get-date -format G
  for($i = $startdate; $i -lt $today; $i=$i.AddDays(1))
  {
     $z = $i -split " "
     $z = [datetime]$z[0]
     $z = Get-Date $z -format G
     "Comparing $z to: "
     $hash_dates.Keys | ? { $hash_dates[$_] -eq $z }
  }
  </code></pre>
  
  <p>I used the <code>-format G</code> and <code>split</code> to ensure the format matches. But the loop never finds any results (even though it loops through 11/1/2016 etc). Am I missing something?</p>