PowerShell script exchange
Post Reply
tkmtech
Novice
Posts: 3
Liked: never
Joined: Sep 26, 2023 3:19 pm
Full Name: Tony Manzi
Contact:

V.12 remove single proxy from job

Post by tkmtech »

I have been trying to find a script to remote a single proxy from all my veeam backup and replication jobs. I have only found ones for v9. I have tried updating this script, but it still will not work.

Code: Select all

$alljobs = Get-VBRComputerBackupjob

foreach ($job in $alljobs) {
    [System.Collections.ArrayList]$origproxies = $job | Get-VBRViProxy | foreach { $_ | Select-Object -ExpandProperty Name}}
    $origproxies.Remove('hamveeam05L.hamep001.com')
    $origproxies.Remove('hamveema05L.hamep001.com')
    $newproxies = Get-VBRViProxy -Name $origproxies
    $job | Set-VBRViProxy -Proxy $newproxies
}
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: V.12 remove single proxy from job

Post by oleg.feoktistov »

Hi Tony,

Try this example:

Code: Select all

$jobs = Get-VBRJob
$proxy = Get-VBRViProxy -Name 'proxy name'
foreach ($job in $jobs) {
  $jobProxies = Get-VBRJobProxy -Job $job
  $proxiesToKeep = $jobProxies | where {$_.Name -ne $proxy.Name}
  Set-VBRJobProxy -Proxy $proxiesToKeep -Job $job
}
Basically, it searches for the proxy you want to remove in a list of job proxies, filters it out from the list and reassigns the list to a job.

Best regards,
Oleg
tkmtech
Novice
Posts: 3
Liked: never
Joined: Sep 26, 2023 3:19 pm
Full Name: Tony Manzi
Contact:

Re: V.12 remove single proxy from job

Post by tkmtech »

I get the following error:
Set-VBRJobProxy : Cannot validate argument on parameter 'Proxy'. The argument is null or empty. Provide an argument
that is not null or empty, and then try the command again.
At line:4 char:26
+ Set-VBRJobProxy -Proxy $proxiesToKeep -Job $job
oleg.feoktistov
Veeam Software
Posts: 1918
Liked: 636 times
Joined: Sep 25, 2019 10:32 am
Full Name: Oleg Feoktistov
Contact:

Re: V.12 remove single proxy from job

Post by oleg.feoktistov »

Are you aiming to remove a single proxy from the list of more than one proxy or just switch to proxy auto detection mode from single proxy usage for each job altogether? Thanks!
Post Reply

Who is online

Users browsing this forum: No registered users and 13 guests