While unattended applications are still used by many legacy systems, they lack support for immediate recovery and fault tolerance provided by more modern service implementation.
This script provides support for alerts based on the absence of the application's process, which implies the application has crashed and needs to be tended to.
$proc = get-process -Name "<process name>"
if([bool]$proc) {
Write-Output "The process is present"
} else {
Write-Output "The process is not present"
$EmailFrom = "<from email>"
$EmailTo = "<to email list (semicolon separated)>"
$Body = "<email body>"
$Subject = "<email subject>"
$SMTPServer = "<SMTP server>"
$SMTPClient = New-Object Net.Mail.SmtpClient($SmtpServer, 25)
$SMTPClient.EnableSsl = $false
$SMTPClient.Send($EmailFrom, $EmailTo, $Subject, $Body)
}
After following these steps, you will automatically receive email alerts whenever an unattended application crashes.