6 de agosto de 2015

Veeam Endpoint Backup > Send Email Notification

1. Criar c:\veeamscript.ps1 com o seguinte conteudo:

###########################################################
# Edit this part:
$youremailserver=    "0.0.0.0"
$sender      =   "origem"
$recipient   =   "destino"
###########################################################

# Put most info into the body of the email:
$TimeGenerated   =    get-eventlog "Veeam Endpoint Backup" -newest 1 -entrytype Information, Warning, Error -source "Veeam Endpoint Backup" | Format-List -property TimeGenerated | out-string
$Source      =   get-eventlog "Veeam Endpoint Backup" -newest 1 -entrytype Information, Warning, Error -source "Veeam Endpoint Backup" | Format-List -property Source | out-string
$EntryType   =   get-eventlog "Veeam Endpoint Backup" -newest 1 -entrytype Information, Warning, Error -source "Veeam Endpoint Backup" | Format-List -property EntryType | out-string
$Message   =   get-eventlog "Veeam Endpoint Backup" -newest 1 -entrytype Information, Warning, Error -source "Veeam Endpoint Backup" | Format-List -property Message | out-string
$InstanceID   =   get-eventlog "Veeam Endpoint Backup" -newest 1 -entrytype Information, Warning, Error -source "Veeam Endpoint Backup" | Format-List -property InstanceID| out-string
$Body      =   " $TimeGenerated Instance-ID: $InstanceID $Message "


# Determine the subject according to the result of the backup:
$hostname = hostname
if ($Message.contains("Success")) {
   $subject = "[Success] Endpoint Backup $hostname"
} elseif ($InstanceID.contains("110")) {
   $subject = "[Started] Endpoint Backup $hostname"
} else {  
   $subject = "[Failed] Endpoint Backup $hostname failed"
}


# Send the email using the powershell object (replace with e.g. blat.exe for older powershell-Versions)
if ($InstanceID.contains("110") -Or  $InstanceID.contains("190")) {
   Send-MailMessage -To $recipient -Subject $subject -From $sender -Body $body -SmtpServer $Youremailserver
} else {
   write-host "I don't want messages on 10010 and 10050 Restorepoint-creation or -remove Emails, skip those"
}


write-host "Script finished with -$instanceID- as the last event-ID"



2. Set the PowerShell Execution Policy to RemoteSigned (run as admin);

3.  Criar tarefa windows para enviar email quando o backup terminar:

In General :
Run whether user is logged on or not
Run with highest privileges
Password stored

Trigger
On an event
Basic
Log : Veeam Endpoint Backup
Source : Veeam Endpoint Backup
Enabled

Action :
Start a program c:\veeamscript.ps1

Settings and conditions by default


Sem comentários:

Enviar um comentário