title: Convert a collection of datetime to yyyy-mm-dd
body: <p>I have a collection of Dates in a text file.</p>
  
  <p>Ex. file.txt</p>
  
  <pre><code>2011-01-01
  
  2011-02-14
  
  2011-02-21
  
  2011-03-17
  
  2011-09-11
  
  2011-11-11
  </code></pre>
  
  <p>I have a function called <code>Important-Dates</code> which holds a collection of <code>[datetime]</code> dates</p>
  
  <p>Ex. Function holds these type of dates</p>
  
  <pre><code>November-11-15 12:00:00 AM
  
  November-11-14 12:00:00 AM
  
  November-11-13 12:00:00 AM
  
  February-14-15 12:00:00 AM
  </code></pre>
  
  <p>I want to <strong>convert</strong> the function dates into the format <code>yyyy-mm-dd</code> and append to the file.txt file</p>
  
  <p>So far, I have this:</p>
  
  <pre><code>$Dates = Important-Dates 
  if ( -not (test-path 'file.txt' -pathtype leaf))
  {
  "{0:yyyy-MM-dd}" -f $Dates | Set-Content 'file.txt'
  exit 1
  }
  else {
  "{0:yyyy-MM-dd}" -f @($_.$Dates) | Add-Content 'file.txt'
  exit 1
  }
  </code></pre>
  
  <p>All I get as a result to the File.txt file is the first date in the Important-Dates list</p>
  
  <p><code>"November-11-15 12:00:00 AM"</code> - which does convert to <code>2015-11-11</code></p>
  
  <p>I want all dates though.  What I am doing wrong?</p>