Created
May 19, 2020 17:03
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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