Created
October 10, 2016 00:10
-
-
Save exchange12rocks/916cf7190205e5eb08f77b34bf57ca71 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
$maxConcurrentJobs = 100 #Max. number of simultaneously running jobs | |
foreach($Object in $Objects) { #Where $Objects is a collection of objects to process. It may be a computers list, for example. | |
$Check = $false #Variable to allow endless looping until the number of running jobs will be less than $maxConcurrentJobs. | |
while ($Check -eq $false) { | |
if ((Get-Job -State 'Running').Count -lt $maxConcurrentJobs) { | |
$ScriptBlock = { | |
#Insert the code of your workload here | |
} | |
Start-Job -ScriptBlock $ScriptBlock | |
$Check = $true #To stop endless looping and proceed to the next object in the list. | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment