Reputation: 31
I am trying to suppress this output
Id Name PSJobTypeName State HasMoreData Location Command
-- ---- ------------- ----- ----------- -------- -------
1 Job1 BackgroundJob Running True localhost ...
3 Job3 BackgroundJob Running True localhost ...
5 Job5 BackgroundJob Running True localhost ...
My code is written as following
foreach($line in $db) {
$job = {
#code
}
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
if ($running.Count -le $jobLimit) {
Start-Job -ScriptBlock $job
} else {
$running | Wait-Job -Any | Out-Null
}
Get-Job | Receive-Job | Out-Null
}
I can not figure out what I am missing to hide this status output...
Upvotes: 1
Views: 3859
Reputation: 13432
Also add | Out-Null
to this line: Start-Job -ScriptBlock $job
.
foreach($line in $db) {
$job = {
#code
}
$running = @(Get-Job | Where-Object { $_.State -eq 'Running' })
if ($running.Count -le $jobLimit) {
Start-Job -ScriptBlock $job | Out-Null
} else {
$running | Wait-Job -Any | Out-Null
}
Get-Job | Receive-Job | Out-Null
}
Upvotes: 5