title: Powershell 5.1: How to iterate over files in parallel
body: <p>I need to copy files dependent on content. So I get all files, read the content and ask a regex if it is valid. After that I want to copy the file to a certain directory.
  My problem is, that there are a lot of source files, so I need to execute this in parallel.</p>
  
  <p>I cannot use PowerShell ForEach-Object Parallel Feature because we are using Powershell Version &lt; 7.0.
  Using a workflow is way to slow.</p>
  
  <pre><code>$folder = "C:\InputFiles"
  workflow CopyFiles
  {
      foreach -parallel ($file in gci $folder *.* -rec | where { ! $_.PSIsContainer })
      {
          //Get content and compare against a regex
          //Copy if regex matches
      }
  }
  CopyFiles
  </code></pre>
  
  <p>Any ideas how to run this in a parallel manner with Powershell?</p>