title: powershell Receive-Job find if State is Failed
body: <p>I have a couple of Start-Job in a powershell script, I'd like to know if there is a better way to know if one of them Failed, this is what I got so far, thanks.</p>
  
  <pre><code>#Wait for the background jobs
  $Jobs | Wait-Job
  #Get the data from them
  $Data = $Jobs | Receive-Job
  
  Write-Host "Printing Data"
  
  
  foreach($job in $Jobs)
  {
      if($job.State -eq "Failed")
      {
          exit -1
      }
  }
  
  exit 0
  </code></pre>