Alert if task delete

is there a way this script could be modified to alert when a task does not exist.
Sadly I do not know much about powershell; so I can’t figure it out where to add something like that