title: Delete files containing string
body: <p>How can I delete all files in a directory that contain a string using powershell?</p>
  
  <p>I've tried something like </p>
  
  <pre><code>$list = get-childitem *.milk | select-string -pattern "fRating=2" | Format-Table Path
  $list | foreach { rm $_.Path }
  </code></pre>
  
  <p>And that worked for some files but did not remove everything. I've tried other various things but nothing is working. </p>
  
  <p>I can easily get the list of file names and can create an array with the path's only using</p>
  
  <pre><code>$lista = @(); foreach ($f in $list) { $lista += $f.Path; }
  </code></pre>
  
  <p>but can't seem to get any command (<code>del</code>, <code>rm</code>, or <code>Remove-Item</code>) to do anything. Just returns immediately without deleting the files or giving errors.</p>
  
  <p>Thanks</p>