Clean up before exiting script

try - finally, did the trick.

try
{

  write-host Starting job.
  start-job  ........
  get-content  ........ -Tail 100 -Wait

}

finally
{

  write-host "Removing job, please wait ...."
  remove-job ......... -Force 2>$null
	
}

When entering ctr-c to exit get-content the job will be removed before the script ends.
Just the way I want it. :slight_smile:

1 Like