I'm trying to implement a GUI to my PowerShell script to simplify a certain process for other users. I have following PowerShell script:
if ($checkBox1.Checked) {
Try{
Start-Job { & K:\sample\adp.cmd }
$listBox1.Items.Add("ADP-Job started...")
}catch [System.Exception]{
$listBox1.Items.Add("ADP --> .cmd File not found!")}
}
if ($checkBox2.Checked) {
Try{
Start-Job { & K:\sample\kdp.cmd }
$listBox1.Items.Add("KDP-Job started...")
}catch [System.Exception]{
$listBox1.Items.Add("KDP --> .cmd File not found!")}
}
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: ADP-Files have been uploaded
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.