Advertisement
Guest User

Untitled

a guest
Dec 29th, 2015
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. Subject: Computer name status [backup was successful]
  2.  
  3. Tuesday, December 29, 2015 2:55 AM
  4. Index : 19160
  5. EntryType : Warning
  6. InstanceId : 4099
  7. Message : Backup was cancelled.
  8. Category : (0)
  9. CategoryNumber : 0
  10. ReplacementStrings : {}
  11. Source : Windows Backup
  12. TimeGenerated : 29-Dec-15 12:42:35 PM
  13. TimeWritten : 29-Dec-15 12:42:35 PM
  14. UserName :
  15.  
  16. $Event = Get-eventlog -log application -Newest 1 -source "Windows Backup"
  17. $Status= $Event.Message
  18. $From = "email@email.com"
  19. $To = "email@email.com"
  20. $SMTPServer = "smtp"
  21. $SMTPPort = "port"
  22. $Username = "email"
  23. $Password = "***"
  24. $Subject = "$computer, $status"
  25. $Body = $event | format-list | out-string
  26. $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
  27. $smtp.EnableSSL = $false
  28. $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
  29. $smtp.Send($From, $To, $subject, $body);
  30. $computer = "$env:computername"
  31.  
  32. $mailMsg = new-object System.Net.Mail.MailMessage $From $To
  33. $mailMsg.Subject = "$computer, $status"
  34. $mailMsg.IsBodyHTML = $true
  35. $mailMsg.Body = $event | FormatTo-HTML -title "System Status for $computer" | out-string
  36. $smtp.Send($mailMsg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement