title: How to do something if a job has finished
body: <p>I'm trying to implement a GUI to my PowerShell script to simplify a certain process for other users. I have following PowerShell script:</p>
  
  <pre><code>if ($checkBox1.Checked)    { 
      Try{
      Start-Job { &amp; K:\sample\adp.cmd }
      $listBox1.Items.Add("ADP-Job started...")
      }catch [System.Exception]{
      $listBox1.Items.Add("ADP --&gt; .cmd File not found!")}
      }
  
      if ($checkBox2.Checked)    { 
      Try{ 
      Start-Job { &amp; K:\sample\kdp.cmd }
      $listBox1.Items.Add("KDP-Job started...")
      }catch [System.Exception]{
      $listBox1.Items.Add("KDP --&gt; .cmd File not found!")}
      }
  </code></pre>
  
  <p>Is there a way to continuously check all running Jobs and do something for each Job that has finished? For Example to print out something like this in my listbox: <code>ADP-Files have been uploaded</code></p>
  
  <p>Since each Job takes around 5 minutes - 4 hours I thought of a while Loop that checks every 5 minutes if a Job is finished, but I can't figure out how to distinguish each Job to do something specific.</p>