Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tdewin/b7a21d5e7a20c984e69dadf07c32dda1 to your computer and use it in GitHub Desktop.
Save tdewin/b7a21d5e7a20c984e69dadf07c32dda1 to your computer and use it in GitHub Desktop.
Veeam Backup & Replication : Map proxies to jobs based on [location:mylocation] in description
asnp veeampssnapin
$reglocation = "\[location:([a-zA-Z0-9]+)\]"
$proxies = Get-VBRViProxy | Group-Object -AsHashTable -AsString -property { if ($_.description -match $reglocation) { $matches[1].trim() } else { "unspecified" }}
foreach($proxygroup in $proxies.GetEnumerator()) {
Write-host ("Found location {0} with {1} proxies" -f $proxygroup.Name,$proxygroup.Value.Count)
}
foreach ($job in (get-vbrjob)) {
if (($job.Description -match $reglocation) -and ($job.SourceType -eq [Veeam.Backup.Model.CDbBackupJobInfo+ESourceType]::VDDK)) {
$location = $Matches[1].Trim()
$mproxies = $proxies[$location]
if ($mproxies.Count -gt 0) {
$null = $job | Set-VBRJobProxy -Proxy $mproxies
Write-host ("{0,-40} set to {1}" -f $job.Name,$location)
} else {
$null = $job | Set-VBRJobProxy -AutoDetect
Write-host ("{0,-40} set to auto" -f $job.Name)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment