Advertisement
1xcalibur1

Alert on Disabled Websites

Sep 30th, 2015
61
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. $Sites = get-website | Where-Object { $_.state -eq "Stopped" } | select Name,State
  17.  
  18. if ( $Sites -eq $NULL ){ exit }
  19. else{
  20.  
  21.     $bod = $sites | ConvertTo-Html -Head $Header -Body "<h1>$env:COMPUTERNAME Disabled Websites</h1>"
  22.    
  23.     Send-MailMessage -From "$env:COMPUTERNAME <email@address>" -To email@address -Body "$bod" -SmtpServer 1.1.1.1 -Subject "CRITICAL: $env:COMPUTERNAME DISABLED Websites!" -BodyAsHtml
  24.    
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement