document.write('
Data hosted with ♥ by Pastebin.com - Download Raw - See Original
  1. # Code Snippet from aperturescience.su
  2. # Parameters
  3.  
  4. [Parameter(Position=1, Mandatory=$false, HelpMessage="hostname(s)")]$hosts = "google.com",
  5.  
  6. # Body
  7.  
  8. #get the services which are auto and are stopped
  9.  $enabledsvc = (Get-WmiObject "win32_service") | Where-Object {($_.startmode -eq "Auto") -and ($_.state -eq "stopped")}
  10.  
  11. #if we get some services
  12. if ($enabledsvc -ne $null)
  13. {
  14.     foreach ($ensvc in $enabledsvc)
  15.     {
  16.         #set $fix to try if we want to restart services
  17.         if ($fix)
  18.         {
  19.             Write-Verbose "$($a[0].displayname)"
  20.             $ensvc.startservice()
  21.             send-email "Service $($a[0].displayname) is not running and I tried to fix it" $false          
  22.         }
  23.         else
  24.         {
  25.             send-email "Service $($a[0].displayname) is not running and I am not fixing it" $false
  26.         }
  27.     }
  28. }
  29. else
  30. {
  31.     send-email "all services running" $true
  32. }
  33.  
  34. # Code Snippet from aperturescience.su
');