PowerShell, Veeam  : Job status report UPDTE

Veeam is a great application, with great Powershell support. You can do anything the application does and more from PowerShell.

I am just getting my teeth into automating a lot of our common Veeam tasks, but here is something simple to get us started.

Here is a simple script for that checks all of the Veeam backup and replication jobs and email a list of servers that have not succeeded.

Add-PSSnapin VeeamPSSnapin

$body = ''
$Jobs = Get-VBRjob
//$Username = "username"
//$Password = "password"
//$SecurePassword = ConvertTp-SecureString $Password -AsPlainText -Force
//$smtpCredentils = New-Object System.management.Automation.PSCredential $Username, $SecurePassword




foreach ($Job in $Jobs)
{
if ($job.GetLastResult() -ne "Success")
    {
        $body += $job.GetLastResult() 
        $body += " "
        $body += $job.Name
        $body += "`n"
    }
}


Send-MailMessage -To "destination address" -From "[email protected]" -Subject "Veeam Job status report" -Body $body -SmtpServer "monitoring.email.net" //-UseSSL -Credential $smtpCredentials

I will be adding more interesting bits as I get to them, so keep your eyes open.

UPDATE - I have added some bits that will allow you to add SMTP credentials. I dont really condone adding passwords to scripts but...