While responding to a post, I figured I’d try to see if i could get all of the email accounts tied to jobs in my Veeam environment to assist.
This script will also show the attached Copy and Tape jobs, so I’ll try to update it with additional logic time permitting.
Either way, It will show if you (or others) have email alerts setup in Veeam jobs. I plan to update if i can have it show Warning, Error, and Success enabled.
$emailPattern = '[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}'
function Get-EmailsFromObject {
param(
[Parameter(Mandatory)]
$obj,
[string]$JobType = "Unknown"
)
$json = $obj | ConvertTo-Json -Depth 5 -Compress -ErrorAction SilentlyContinue
if ($json) {
$matches = ($json | Select-String -Pattern $emailPattern -AllMatches).Matches
foreach ($m in $matches) {
[PSCustomObject]@{
JobName = $obj.Name
JobType = $JobType
Email = $m.Value
}
}
}
}
$allEmails = @()
# Backup Jobs
Get-VBRJob | ForEach-Object { $allEmails += Get-EmailsFromObject $_ -JobType "Backup Job" }
# Backup Copy Jobs
Get-VBRBackupCopyJob | ForEach-Object { $allEmails += Get-EmailsFromObject $_ -JobType "Backup Copy Job" }
# SureBackup Jobs
Get-VBRSureBackupJob | ForEach-Object { $allEmails += Get-EmailsFromObject $_ -JobType "SureBackup Job" }
# Agent Jobs
Get-VBRComputerBackupJob | ForEach-Object { $allEmails += Get-EmailsFromObject $_ -JobType "Agent Job" }
# Tape Jobs
Get-VBRTapeJob | ForEach-Object { $allEmails += Get-EmailsFromObject $_ -JobType "Tape Job" }
# Deduplicate and sort by JobType and JobName
$allEmails | Sort-Object JobType, JobName -Unique | Format-Table -AutoSize
