Advertisement
1xcalibur1

Alert on Disabled App Pools

Sep 30th, 2015
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Import-Module -Name webadministration
  2.  
  3. $Header = @"
  4. <style>
  5. TABLE {border-width: 1px;border-style: solid;border-color: black;border-collapse: collapse;}
  6. TH {border-width: 1px;padding: 3px;border-style: solid;border-color: black;background-color: #6495ED;}
  7. TD {border-width: 1px;padding: 3px;border-style: solid;border-color: black;}
  8. </style>
  9. <title>
  10. Title of my Report
  11. </title>
  12. "@
  13.  
  14.  
  15.  
  16. $Apps = ls IIS:\AppPools | Where-Object { $_.state -eq "Stopped" } | select Name, State
  17.  
  18. if ( $Apps -eq $NULL ){ exit }
  19. else{
  20.  
  21.     $bod = $Apps | ConvertTo-Html -Head $Header -Body "<h1>$env:COMPUTERNAME Disabled AppPools</h1>"
  22.     Send-MailMessage -From "$env:COMPUTERNAME <fromemail@address.com>" -To toemail@address.com -Body "$bod" -SmtpServer 1.1.1.1 -Subject "CRITICAL: $env:COMPUTERNAME DISABLED AppPools!" -BodyAsHtml
  23.    
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement