PowerShell script exchange
Post Reply
slide999
Novice
Posts: 5
Liked: never
Joined: Sep 25, 2014 9:40 pm
Full Name: Kevin
Contact:

Script to remove a retired proxy server from multiple jobs?

Post by slide999 »

Greetings,

I have (2) proxy servers that no longer exist in our environment but are assigned to 125 jobs (manually). Needless to day, I must remove them from all jobs before Veeam allows me to remove the proxy servers from inventory. I have searched high and low for the Veeam PS syntax to remove these servers from the individual jobs, but only have found examples for adding them:

$Job = Get-VBRJob -name $server.serverjob
$Proxy = Get-VBRViProxy -name "ProxyToAdd"
$Type = [Veeam.Backup.Model.CJobProxyInfo+EType]::ESource
[Veeam.Backup.Core.CJobProxy]::Create($job.id, $proxy.id, $type)

I have replaced 'create' with 'delete' and 'remove' to no avail. Any help would be greatly appreciated!

Case # 03316246

Kevin
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: Script to remove a retired proxy server from multiple jobs?

Post by jhoughes »

If you are trying to explicitly set the same existing proxies minus the 2 proxies, then your easiest option is probably to get all of your job objects and run through a loop of the following:]

1. Get the name of all proxies assigned to each job
2. Remove the names of retired proxies from the arraylist
3. Get the objects of the remaining proxies
4. Set the job with the remaining proxies

Here's an example of running this through my lab to remove the proxies named 'ausveeampxy01.lab.fullstackgeek.net' and 'ausveeampxy02.lab.fullstackgeek.net'.

Modify the proxy names as necessary, and you may want to run this against a few jobs first to validate that it is performing what you are trying to do:

Code: Select all

$alljobs = Get-VBRJob

foreach ($job in $alljobs) {
    [System.Collections.ArrayList]$origproxies = $job | Get-VBRJobProxy | foreach { $_ | Select-Object -ExpandProperty Name}
    $origproxies.Remove('ausveeampxy01.lab.fullstackgeek.net')
    $origproxies.Remove('ausveeampxy02.lab.fullstackgeek.net')
    $newproxies = Get-VBRViProxy -Name $origproxies
    $job | Set-VBRJobProxy -Proxy $newproxies
}
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
slide999
Novice
Posts: 5
Liked: never
Joined: Sep 25, 2014 9:40 pm
Full Name: Kevin
Contact:

Re: Script to remove a retired proxy server from multiple jobs?

Post by slide999 »

Hi Joe,

Thanks for the quick reply - will give it a go.

Cheers,
Kevin
Post Reply

Who is online

Users browsing this forum: No registered users and 14 guests