Advertisement
Guest User

Untitled

a guest
Mar 18th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.03 KB | None | 0 0
  1. $A = get-service vss
  2. if ($A.Status -eq "Stopped") {$A.start()} elseIf ($A.status -eq "Running") {Write-Host -ForegroundColor Yellow $A.name "is running"}
  3.  
  4. ping 1.1.1.1 -n 6 # wait for 6 seconds
  5.  
  6. $A = get-service w32time
  7. if ($A.Status -eq "Stopped") {$A.start()} elseIf ($A.status -eq "Running") {Write-Host -ForegroundColor Yellow $A.name "is running"}
  8.  
  9. $services = Get-Service "VSS, W32time"
  10. foreach($service in $services){$service.Name}
  11. if ($Service.Status -ne "Running") {
  12. $Body = "$($service.DisplayName) is not running"
  13. } else {
  14. $Body = "$($service.Displayname) is running "
  15. }
  16.  
  17. $From = "email"
  18. $To = "emails"
  19. $SMTPServer = "smtp"
  20. $SMTPPort = "587"
  21. $Username = "email"
  22. $Password = "password"
  23. $Body =$body
  24. $Subject = "$computer$ status"
  25. $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
  26. $smtp.EnableSSL = $false
  27. $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
  28. $smtp.Send($From, $To, $subject, $body);
  29. $computer = $env:computername
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement