kjacobsen

Service Monitoring and Recovery with PowerShell

Apr 2nd, 2012
328
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Code Snippet from aperturescience.su
  2.  
  3. $services = Get-Service $query
  4. foreach ($svc in $services)
  5. {
  6.     if ($svc.status -ne "running")
  7.     {
  8.         try {
  9.             $svc.start()
  10.         } catch {
  11.        
  12.         }
  13.         send-email "One or more services were not running. $($svc.displayname)" $false
  14.     }
  15. }
  16.  
  17. # Code Snippet from aperturescience.su
Advertisement
Add Comment
Please, Sign In to add comment