title: Powershell script to delete old files
body: <p>The following script will delete files in a named directory that are older than 14 days and write to a <code>.txt</code> with the path and the files deleted (found this script on another forum..credit to shay):</p>
  
  <pre><code>dir c:\tmp -recurse | where {!$_.PsIsContainer -AND $_.lastWriteTime -lt (Get-Date).AddDays(-14) } | select LastWriteTime,@{n="Path";e={convert-path $_.PSPath}} | tee c:\oldFiles.txt | Remove-Item -force -whatif
  </code></pre>
  
  <p>I have 3 questions:</p>
  
  <ol>
  <li>What is <code>-lt</code> and what is <code>-le</code> and what is <code>-gt</code>? When would I use each one</li>
  <li>The script above only deletes file...how can I delete folders as well?</li>
  <li>The script above is based off of <code>LastWriteTime</code> .. what about <code>CreatedDate</code> or <code>LastAccessed</code> time?</li>
  </ol>