Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Subject: Computer name status [backup was successful]
- Tuesday, December 29, 2015 2:55 AM
- Index : 19160
- EntryType : Warning
- InstanceId : 4099
- Message : Backup was cancelled.
- Category : (0)
- CategoryNumber : 0
- ReplacementStrings : {}
- Source : Windows Backup
- TimeGenerated : 29-Dec-15 12:42:35 PM
- TimeWritten : 29-Dec-15 12:42:35 PM
- UserName :
- $Event = Get-eventlog -log application -Newest 1 -source "Windows Backup"
- $Status= $Event.Message
- $From = "email@email.com"
- $To = "email@email.com"
- $SMTPServer = "smtp"
- $SMTPPort = "port"
- $Username = "email"
- $Password = "***"
- $Subject = "$computer, $status"
- $Body = $event | format-list | out-string
- $smtp = New-Object System.Net.Mail.SmtpClient($SMTPServer, $SMTPPort);
- $smtp.EnableSSL = $false
- $smtp.Credentials = New-Object System.Net.NetworkCredential($Username, $Password);
- $smtp.Send($From, $To, $subject, $body);
- $computer = "$env:computername"
- $mailMsg = new-object System.Net.Mail.MailMessage $From $To
- $mailMsg.Subject = "$computer, $status"
- $mailMsg.IsBodyHTML = $true
- $mailMsg.Body = $event | FormatTo-HTML -title "System Status for $computer" | out-string
- $smtp.Send($mailMsg)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement