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