Code: Select all
Backup_FILE01
Backup_FILE47
Replication_FILE
(C:\Scripts\Veeam\NotifyOfDisabledJobs.bat)
Code: Select all
powershell.exe c:\scripts\Veeam\NotifyOfDisabledJobs.ps1
Code: Select all
<#
****************************************************************************************
PowerShell script that checks for disabled jobs and sends an e-mail containing the list of disabled jobs
By winnt posted to Veeam forum on May 8, 2022
You will need to install the Veeam Powershell module if you don't run it from the Veeam server
You need to change the e-mail fields to match yours
You need to change the $ScriptDir and $ReportDir variables, or leave them as-is and make
sure the paths exist for this script file.
Create the file NotifyOfDisabledJobs_EXCLUSIONS.IN and add any job names (or partial names) to exclude.
Here is an example file:
--- NotifyOfDisabledJobs_EXCLUSIONS.IN ---
Backup_Server01
Backup_Server02
Replication_Server0
--------------------------------------------
****************************************************************************************
#>
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
$ScriptDir = 'C:\Scripts\Veeam'
$JobExclusionFilterFile = "$ScriptDir\NotifyOfDisabledJobs_EXCLUSIONS.IN"
$MailTo = "YourName@example.com"
$MailFrom = "YourVeeamBackupServer@example.com"
$MailSubject = "ALERT: Veeam jobs disabled"
$SMTPServer = "smtpserver.example.com"
$DisabledJobs = Get-VBRJob | where {$_.info.IsScheduleEnabled -eq $False }
IF ($DisabledJobs) {
IF ((Test-Path -Path $JobExclusionFilterFile) -and ((-NOT [string]::IsNullOrWhiteSpace((Get-Content $JobExclusionFilterFile))))) {
$JobsToExclude = Get-Content "$JobExclusionFilterFile"
$DisabledJobsWithExclusions = $DisabledJobs.Name |
Select-String -Pattern $JobsToExclude -NotMatch
$DisabledJobsWithExclusions = $DisabledJobsWithExclusions | Out-String
$JobsToExclude = $JobsToExclude | Out-String
$FinalReport = $DisabledJobsWithExclusions
} ELSE {
Write-Host "No job exclusion filter set"
$JobsToExclude = "None"
$FinalReport = $DisabledJobs.Name | Out-String
}
$EmailBody = "Please review the following disabled Veeam jobs and re-enable, re-enable and remove schedule, or add to exceptions list file:
$FinalReport
Jobs with the following search filters are excluded from the report:
$JobsToExclude"
$EmailBody
$MailMessage = @{
To = $MailTo
From = $MailFrom
Subject = $MailSubject
Body = $EmailBody
Smtpserver = $SMTPServer
} #End_MailMessage
Send-MailMessage @MailMessage
} # EndIf_DisabledJobs
ELSE {
Write-Host "No disabled jobs"}