Last active
August 15, 2016 10:09
-
-
Save MVKozlov/a093877010c213564dd4f638724ff9d4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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