PowerShell script exchange
Post Reply
kefoster
Novice
Posts: 8
Liked: 2 times
Joined: Jun 21, 2012 7:34 pm
Full Name: Kevin Foster
Contact:

Set-VBRJobProxy - Multiple Proxies

Post by kefoster »

I want to specify multiple proxies for specific jobs via powershell. It appears Set-VBRJobProxy can only set a single proxy to a Job. Is there a way around this? Any examples would be great.

Thank you,

Kevin
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by veremin »

Proxy (-Proxy) parameter of the said commandlet accepts multiple proxy entities, so, setting array of proxies should work without any issues, like:

Code: Select all

Set-VBRJobProxy -Job $Job -Proxy $Proxies
If that doesn't happen, can you please post a code you're trying to execute?

Thanks.
kefoster
Novice
Posts: 8
Liked: 2 times
Joined: Jun 21, 2012 7:34 pm
Full Name: Kevin Foster
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by kefoster »

I thought the same thing but when I run the following code I get the error in red. I am using the names of the proxies as they are displayed in the console.

Code: Select all

$Proxies = "fakeproxy107v.somedomain.com","fakeproxy108v.somedomain.com","fakeproxy109v.somedomain.com","fakeproxy113v.somedomain.com","fakeproxy114v.somedomain.com","fakeproxy115v.somedomain.com","fakeproxy116v.somedomain.com","fakeproxy117v.somedomain.com","fakeproxy118v.somedomain.com"
$Jobs = Get-VBRJob | Where Name -Like "AUS_TEST*"
foreach ($Job in $jobs)
{
        Set-VBRJobProxy -Job $Job.Name -Proxy $Proxies
}
Set-VBRJobProxy : Cannot bind parameter 'Proxy'. Cannot convert the "fakeproxy107v.somedomain.com" value of type
"System.String" to type "Veeam.Backup.Core.IProxy".
At line:6 char:47
+ Set-VBRJobProxy -Job $Job.Name -Proxy $Proxies
+ ~~~~~~~~
+ CategoryInfo : InvalidArgument: (:) [Set-VBRJobProxy], ParameterBindingException
+ FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.PowerShell.Command.SetVBRJobProxy
PTide
Product Manager
Posts: 6408
Liked: 724 times
Joined: May 19, 2015 1:46 pm
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by PTide »

It seems that you are giving it an array of strings, while it expects to get an array of objects (proxy is an object) Please try the following syntax:

$myArray=$var1,$var2,$var3,$var4

where each $varN is Get-VBRViProxy -Name "Proxy Name"
kefoster
Novice
Posts: 8
Liked: 2 times
Joined: Jun 21, 2012 7:34 pm
Full Name: Kevin Foster
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by kefoster » 1 person likes this post

Thank you! I used the following to get the Proxies I needed.

Code: Select all

$Proxies = Get-VBRViProxy | where Name -Like "*aus*"
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by veremin »

Also, -Job parameter should be of a different type. Currently, you're trying to pass a string object to it ($Job.name is a string), while it accepts CBackupJob entities, instead. So, you should use $Job variable, not $Job.name. Thanks.
kefoster
Novice
Posts: 8
Liked: 2 times
Joined: Jun 21, 2012 7:34 pm
Full Name: Kevin Foster
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by kefoster » 1 person likes this post

v.Eremin wrote:Also, -Job parameter should be of a different type. Currently, you're trying to pass a string object to it ($Job.name is a string), while it accepts CBackupJob entities, instead. So, you should use $Job variable, not $Job.name. Thanks.
Good to know. It worked using the $Job.Name so I got lucky! Still trying to figure this all out!

Thank you all for your help!

PS Just saw the big red print about POSTING AN ERROR... I did have a case but they said they couldn't help and gave me the URL for this forum Case # 01073141
veremin
Product Manager
Posts: 20270
Liked: 2252 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

Re: Set-VBRJobProxy - Multiple Proxies

Post by veremin »

Glad to hear you've sorted it our.

Support case is required while posting about technical issues and similar. In the meantime, if you're looking for a general advice or need some help with scripting it's OK to post without it.

Thanks.
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests