title: Outputing Remove-Item to a log file
body: <p>Scanning a directory for a specific set of files and sorting them by date. Keeping 7 of the LATEST copies of the file regardless of date, and removing the oldest if over 7. I am having a hard time producing a log file showing the deletes since <code>Remove-Item</code> has no output.</p>
  
  <p>Below is a copy of my code:</p>
  
  <pre><code>$path = "C:\- Deploy to Production -\Previous Deploys\*_*_BOAWeb.rar" #BOA 
  $files = Get-ChildItem -Path $path -Recurse | Where-Object {-not $_.PsIsContainer}
  $keep = 7
  if ($files.Count -gt $keep) {
    $files | Sort-Object CreationTime |
      Select-Object -First ($files.Count - $keep) |
      Remove-Item -Force 
  }
  </code></pre>