I need to change one of my proxies on multiple veeam backup jobs (vmware)
Proxy das-071-vol02 needs to be removed and das-072-vol02 needs to be added only to the jobs where das-071-vol02 is currently configured. (Manual Selection)
The following code gives me a list of all jobs (63) where das-071-vol02 is used. Can anyone assist with a replace logic for VBR proxy from das-071-vol02 to das-072-vol02, while leaving other proxies configured on the 63 jobs as is?
$oldProxyName = "das-071-vol02"
$newProxyName = "das-021-vol02"
# Get the old proxy
$oldProxy = Get-VBRViProxy -Name $oldProxyName
# Check if the old proxy exists
if ($oldProxy -ne $null) {
# Get the new proxy
$newProxy = Get-VBRViProxy -Name $newProxyName
# Check if the new proxy exists
if ($newProxy -ne $null) {
# Replace the old proxy with the new proxy in all backup jobs
Get-VBRJob | ForEach-Object {
$jobOptions = $_.GetOptions()
$jobOptions.Proxy = $newProxy
$_.SetOptions($jobOptions)
Write-Host "Replaced proxy for job $($_.Name) from $oldProxyName to $newProxyName"
}
# Remove the old proxy
Remove-VBRViProxy -Proxy $oldProxy
Write-Host "Removed old proxy $oldProxyName"
} else {
Write-Host "New proxy $newProxyName not found"
}
} else {
Write-Host "Old proxy $oldProxyName not found"
}
I am getting Cannot find an overload for "Create" and the argument count: "3".
At line:5 char:1
+ [Veeam.Backup.Core.CJobProxy]::Create($job.Id, $newProxy.Id, $proxyTy ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodException
+ FullyQualifiedErrorId : MethodCountCouldNotFindBest
$oldProxyName = 'das-071-vol02'
$newProxyName = 'das-072-vol02'
$backupJobs = Get-VBRJob
# Loop through each job
foreach ($job in $backupJobs) {
# Get the old and new proxies for each job
$oldProxy = Get-VBRViProxy -Name $oldProxyName
$newProxy = Get-VBRViProxy -Name $newProxyName
if ($oldProxy -and $newProxy) {
# Create a new proxy entry for the job
$proxyType = [Veeam.Backup.Model.CJobProxyInfo+EType]::ESource
[Veeam.Backup.Core.CJobProxy]::Create($job.Id, $newProxy.Id, $proxyType)
[Veeam.Backup.Core.CJobProxy]::DeleteByProxy($oldProxy.Id)
Write-Warning "Proxy replacement completed for job: $($job.Name)"
} else {
Write-Warning "Error: Old or new proxy not found for job: $($job.Name)"
}
}