title: Powershell - Skip files that cannot be accessed
body: <p>I'm trying to recursively delete all files and folders inside of a folder with Powershell via:</p>
  <pre><code>Remove-Item &quot;C:\Users\user\Desktop\The_folder\*&quot; -Recurse -Force
  </code></pre>
  <p>My problem is that whenever I run it, I get:</p>
  <pre><code>Cannot remove item C:\Users\user\Desktop\The_folder\Delete: The process cannot access the file 'C:\Users\user\Desktop\The_folder\Delete' because it is being used by another process.
  </code></pre>
  <p>How do I skip any files I don't have access to because they are in use <em>(i.e. the same way a user would via GUI asking if wanting to skip all files that cannot be accessed)</em>?</p>
  <ul>
  <li>I tried the following, but received error:
  <pre><code>Remove-Item &quot;C:\Users\mstjean\Desktop\The_folder\*&quot; -Recurse -Force -ErrorAction Continue
  
    Remove-Item : Cannot remove item C:\Users\mstjean\Desktop\The_folder\Delete:
      The process cannot access the file 'C:\Users\mstjean\Desktop\The_folder\Delete'
      because it is being used by another process.
  
    At line:1 char:1
      + Remove-Item &quot;C:\Users\mstjean\Desktop\The_folder\*&quot; -Recurse -Force -ErrorAction ...
  
      + CategoryInfo: WriteError: (C:\Users\mstjea...e_folder\Delete:DirectoryInfo) [Remove-Item], IOException
      + FullyQualifiedErrorId:    RemoveFileSystemItemIOError,Microsoft.PowerShell.Commands.RemoveItemCommand
  </code></pre>
  </li>
  </ul>