Detect unresponsive applications using Powershell

Change the variables, save as a ps1 and schedule this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
$to  = "user@email.com", "user2@email.com"
$from  = "user@email.com"
$smtp = "address of SMTP server"
$engine = $env:computername
$log = "C:\pathto\log.txt"
$now=Get-Date -format "dd-MMM-yyyy HH:mm"

$Processes = Get-Process -EA Stop          
$nProcesses = @($Processes | ? { $_.Responding -eq $false })
if($nProcesses) {          
  foreach($nProcess in $nProcesses) {          
   $nProcess | select Name, id, MainWindowTitle, Responding  
                Write-Host "Non-Responsive Processes found!"
                $msg = "Non responsive processes found on $engine! -- $nProcess"
                $body = "Non responsive processes found on $engine!    

                $nProcess"

                Add-content $log -value $now
                Add-content $log -value $msg
                Send-Mailmessage -From $from -To $to -Subject $msg -Body $body -Priority High -dno onSuccess, onFailure -SmtpServer $smtp
 }          
 }

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">