title: ItemNotFoundException calling Remove-Item from pipeline on files outside the curent directory
body: <p>Suppose I have the following files I'd like to remove from multiple directories.</p>
  
  <pre><code>PS d:\path&gt; $files = gci -path . -Recurse -File
  
  PS d:\path&gt; $files
  d:\path\foo.txt
  d:\path\sub\bar.txt
  </code></pre>
  
  <p>I use <code>foreach</code> to call <code>Remove-Item</code>.</p>
  
  <pre><code>PS d:\path&gt; $files | foreach { Remove-Item -Path $_ -WhatIf }
  What if: Performing the operation "Remove File" on target "D:\path\foo.txt".
  Remove-Item : Cannot find path 'D:\path\bar.txt' because it does not exist.
  At line:1 char:19
  + $files | foreach { Remove-Item -Path $_ -WhatIf }
  +                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : ObjectNotFound: (D:\path\bar.txt:String) [Remove-Item], ItemNotFoundException
      + FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.RemoveItemCommand
  </code></pre>
  
  <p>It would seem that when passed a recursive list of files, <code>Remove-Item</code> always tries to remove a file from the current directory.  It can remove <strong>d:\path\foo.txt</strong> just fine.  But it throws an error trying to remove <strong>d:\path\bar.txt</strong>, because there is no such file.  The file it should be deleting is located in <strong>d:\path\sub\bar.txt</strong>.</p>
  
  <p>Note that the following code works fine, presumably because the <code>Get-ChildItem</code> is not recursive.</p>
  
  <pre><code>PS D:\path&gt; del .\sub\bar.txt -WhatIf
  What if: Performing the operation "Remove File" on target "D:\path\sub\bar.txt".
  
  PS D:\path&gt; gci .\sub\bar.txt | % { del $_ -WhatIf }
  What if: Performing the operation "Remove File" on target "D:\path\sub\bar.txt".
  </code></pre>
  
  <p>Is this a bug in PowerShell, or am I not using it right?  Is there a different prescribed way to delete files recursively, subject to pipeline filtering?</p>
  
  <p>Other notes:</p>
  
  <ul>
  <li>Including the <code>-WhatIf</code> parameter doesn't affect the issue here; it just forces <code>Remove-Item</code> to print output instead of deleting my test files.</li>
  <li>I can't just pass <code>-Recurse</code> to <code>Remove-Item</code> because in my actual code I'm doing non-trivial filtering on the pipeline to choose which files to delete.</li>
  <li>This is Powershell v4.0 on Windows 8.1</li>
  </ul>