Powershell Monitor Job Status

This is the framework for a basic monitoring of a PowerShell job.

The basic steps are to store the current jobs in to a variable named $jobs. Loop through the variable and increment $jobcount if the state of the job does not equal “Completed”. The script keeps looping until $jobcount is 0.

Lines 11 and 12 are merely demonstrative. You could put anything here you want…

   $jobcount = 0
   $jobs = Get-Job
   foreach ($job in $jobs)
    if ($job.state -ne "Completed"){
   Write-Verbose "Active jobs: $jobcount"
   Start-Sleep -Seconds 5
until ($jobcount -lt 1)