Please see below. For whatever reason I can't kill off any on the .exe process running. Randomly I have seen this script work which is why I think there is something else going on.
All that I see is the whole script has worked when testing but then I promote to prod it just fires of the email part. Email part is fine.
Will this code guarantee a kill of the processes even if they are hung.
$process = Get-Process -Name "IVR1","IVR2","IVR3"
$IVR1path = "C:\IVR1"
$IVR2path = "C:\IVR2"
$IVR3path = "C:\IVR3"
Get-Process $process -ErrorAction SilentlyContinue
if ($process) {
Get-Process -Name $process | kill -PassThru
Start-Sleep -s 5
cd $IVR1path
Start-Process ".\IVR1.exe"
cd IVR2path
Start-Process ".\IVR2.exe"
cd IVR3path
Start-Process ".\IVR3.exe"
cd ..
cd ..
$From = "IVR1@example.com.au"
$To = "myemail@example.com.au"
$cc = "myemail@example.com.au"
$Subject = "**TEST** - IVR1 has been recovered"
$Body = "The IVR has been successfully recovered"
$SMTPServer = "mail.example.com.au"
Send-MailMessage -From $From -to $To -cc $cc -Subject $Subject -Body $Body -SmtpServer $SMTPServer
}