UPDATE (Feb 2024):
It was brought to my attention recently that some of the cmdlets have changed in v12.x that may have broken one or more of the above scripts. I’ve rewritten the one that was pointed out (Veeam Agent Jobs) and tested to make sure it works. I can’t vouch for the others, but will try to get around to updating them all (if needed) and posting the updates here. Just be sure if you’re on 12.x or newer that you do thorough checks to confirm it works in a safe environment before attempting to run anything in production.
------------------------------------------------------
Hello again, everyone! Just sharing another useful PowerShell script to enable/disable Health Checks for multiple jobs. It’s handy whenever you have a large number of jobs which all need to be adjusted and would take a significant amount of time to do so. Usually I wouldn’t share such a short script, but the way to locate and adjust this particular option in a job via PowerShell can be a little confusing if you’re a PowerShell novice.
I decided to provide multiple examples for editing various job types and not just an all-or-nothing approach. I hope someone finds these useful! If I missed anything, please let me know and I’ll include it.
NOTE: These are all examples of how to disable Health Checks. To flip it around to have it enable Health Checks, simply change $false to $true.
For ALL jobs:
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
foreach ($job in Get-VBRJob) {
$options = Get-VBRJobOptions -Job $job
$options.GenerationPolicy.EnableRechek = $false
Set-VBRJobOptions -Job $job -Options $options | Out-Null
}
For just Backup Jobs (VMware/HyperV):
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
foreach ($job in Get-VBRJob) {
if ($job.JobType -eq 'Backup') {
$options = Get-VBRJobOptions -Job $job
$options.GenerationPolicy.EnableRechek = $false
Set-VBRJobOptions -Job $job -Options $options | Out-Null
}
}
For just Agent Backup (Managed by VBR) Jobs:
(NOTE: Updated and improved for v12+)
do {
#Ask user for input to determine which actions to perform.
$userInput = Read-Host "Enter the number that corresponds to the action you would like to perform, then press 'ENTER':
(NOTE: The 'HealthCheckOptions' parameter is not available for backup policies that are applied to Linux computers.)
1. DISABLE health checks for ALL Veeam Agent for Windows jobs.
2. ENABLE heath checks for ALL Veeam Agent for Windows jobs.
3. Exit script and perform no actions."
#Control loop flag. Will loop until user enters valid input.
$isValidInput = $true
#Switch logic that performs actions based off the user selected option.
switch ($userInput) {
#Disables health checks for all jobs.
"1" {
Write-Host "Disabling health checks for ALL jobs..."
$jobs = Get-VBRComputerBackupJob | ? { $_.OSPlatform -eq "Windows" }
foreach ($job in $jobs) {
$hcOpts = $job.HealthCheckOptions
$hcOpts = Set-VBRHealthCheckOptions -Options $job.HealthCheckOptions -Enable:$False
Set-VBRComputerBackupJob -Job $job -HealthCheckOptions $hcOpts | Out-Null
}
Break
}
#Enables health checks for all jobs.
"2" {
Write-Host "Enabling health checks for ALL jobs..."
$jobs = Get-VBRComputerBackupJob | ? { $_.OSPlatform -eq "Windows" }
foreach ($job in $jobs) {
$hcOpts = $job.HealthCheckOptions
$hcOpts = Set-VBRHealthCheckOptions -Options $job.HealthCheckOptions -Enable:$True
Set-VBRComputerBackupJob -Job $job -HealthCheckOptions $hcOpts | Out-Null
}
Break
}
#Exits script without performing any actions.
"3" {
Write-Host "No actions performed. Exiting script in 3 seconds..."
Start-Sleep -Seconds 3
Exit
}
#If user enters invalid input, console is cleared and the user is re-prompted to enter a valid option.
Default {
$isValidInput = $false
Clear-Host
Write-Host "Invalid input. Please enter a valid number (1, 2, or 3).`n"
}
}
} while (!($isValidInput))
For just Backup Copy (VMware/Hyper-V/Agent) Jobs:
Add-PSSnapin -Name VeeamPSSnapIn -ErrorAction SilentlyContinue
foreach ($job in Get-VBRJob){
if ($job.JobType -eq 'BackupSync' -or $job.JobType -eq 'SimpleBackupCopyPolicy') {
$options = Get-VBRJobOptions -Job $job
$options.GenerationPolicy.EnableRechek = $false
Set-VBRJobOptions -Job $job -Options $options | Out-Null
}
}