Skip to content

Instantly share code, notes, and snippets.

@MVKozlov
Last active August 15, 2016 10:09
Show Gist options
  • Save MVKozlov/a093877010c213564dd4f638724ff9d4 to your computer and use it in GitHub Desktop.
Save MVKozlov/a093877010c213564dd4f638724ff9d4 to your computer and use it in GitHub Desktop.
function Test-RSJob([bool]$FullPiping=$true) {
$ScriptBlock = { "{0}: {1}" -f $_, [DateTime]::Now; Start-Sleep -Seconds 5 }
$params = @{ Batch='throttletest'; ScriptBlock=$ScriptBlock; Throttle=5 }
if ($FullPiping) {
$jobs = 1..25 | Start-RSJob @params
}
else {
$jobs = 1..25 | Foreach-Object { $_ | Start-RSJob @params }
}
$jobs | Wait-RSJob | Receive-RSJob
$jobs | Remove-RSJob
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment