Change Proxy in Jobs

PowerShell script exchange

Change Proxy in Jobs

Veeam Logoby sidavid » Fri Nov 02, 2012 2:23 am


I want to change the proxy setting of several jobs and specified a proxy:

Code: Select all
Add-PSSnapin "VeeamPSSnapIn"
Get-VBRJob | where {$"JobName")} | foreach {
$vbrjobname = $_.Name
$job = Get-VBRJob | ?{$_.Name -eq $vbrjobname}
$vo = $job.GetOptions()
$vo.JobOptions.SourceProxyAutoDetect = $False
$proxy = Get-VBRViProxy -name "backupproxy1"
$Type = [Veeam.Backup.Model.CJobProxyInfo+EType]::ESource
[Veeam.Backup.Core.CJobProxy]::Create($, $, $type)

With this script, the backup proxy setting is set to use the backup proxy servers specified below but all the proxys are checked, I want to uncheck all and specified mine. Is it possible?

Many thanks for your help

Posts: 60
Liked: never
Joined: Sun Jan 01, 2006 1:01 am

Re: Change Proxy in Jobs

Veeam Logoby v.Eremin » Tue Nov 13, 2012 12:48 pm

Hi, David.

It took me for a little while but I think, I managed to find a solution for your issue.
So, here it’s with some commentary.

Code: Select all
asnp VeeamPSSnapin

#First part of the script is responsible for disabling SourceProxyAutoDetection

$Job = Get-VBRJob | ?{$_.Name –eq “Name of your Job”}
$vo= $job.GetOptions()
$vo.JobOptions.SourceProxyAutoDetect = $False

#After having done that, our goal is to exclude from our job all proxies except for one.
#Thus, second part of the script is checking proxies which names don't coincide with the name of the proxy we're going to leave.
#The result of that process is being saved in $Proxies list.
#In the end, within the cycle, we delete all of such proxies, meanwhile create the only one ($ProxytoAdd).
#Little note: $ProxyType = 0 means SourceProxy, 1 - TargetProxy.
$ProxyType = 0
$ProxyToAdd = Get-VBRViProxy| ?{$_.Name –eq "Name of proxy you're going to leave"}
$Proxies= Get-VbrViProxy | ?{$_.Name –ne $ProxyToAdd}

foreach($ProxytoDelete in $Proxies)
    foreach($ProxyInfo in ([Veeam.Backup.DBManager.CDBManager]::Instance.JobProxies.GetJobProxies($, $ProxyType)))
        if($ProxyInfo.ProxyId -eq $
[Veeam.Backup.Core.CJobProxy]::Create($, $, $ProxyType)

That’s all.

Even though, i've used it in earnest, it's still nothing but draft-work with a lot of space for improvement. Consequently, all commentary is higly-apprecieated.

Feel free to use and/or share it.
And don’t forget to try it before implementing.

Hope this helps.
Veeam Software
Posts: 13255
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Return to PowerShell

Who is online

Users browsing this forum: No registered users and 5 guests