Skip to content

Instantly share code, notes, and snippets.

@kgadek
Created October 28, 2014 23:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kgadek/e402a3edb18bd0e0682d to your computer and use it in GitHub Desktop.
Save kgadek/e402a3edb18bd0e0682d to your computer and use it in GitHub Desktop.
Powershell parallel
cls
"foo.txt", "bar.txt" | %{
$ScriptBlock = {
param($name)
Write-Host "[processing '$name' inside the job]"
Get-Content "$name" | %{
Write-Host "Content: $_"
}
Start-Sleep 1
}
Write-Host "processing $_..."
Start-Job $ScriptBlock -ArgumentList $_
}
While (Get-Job -State "Running") { Start-Sleep 1 }
Get-Job | Receive-Job
Remove-Job *
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment