PowerShell script exchange
Post Reply
chriswahl
Lurker
Posts: 2
Liked: never
Joined: Mar 08, 2010 12:51 am
Full Name: Chris Wahl

Powershell script in v5

Post by chriswahl » Oct 22, 2010 3:50 am

I use a powershell script to string along jobs in series for the nightly backup. After upgrading to B&R v5 I've noticed that the old script is not working.

The production script was a series of lines like this for B&R v4:

Code: Select all

start-vbrjob -name "Jobname1"
start-vbrjob -name "Jobname2"
I did a get-help on the cmdlet and see that the structure is a bit different, which is why the -name input was failing:

Code: Select all

Start-VBRJob [-Job] <CBackupJob[]> [-FullBackup] [-RetryBackup] [-RunAsync]
 [-WarningAction <ActionPreference>] [-WarningVariable <String>] [<CommonPa
rameters>]
However, I'm having no luck using the -job argument either. I'm not sure what type "Veam.Backup.Core.CbackupJob" is.

Code: Select all

Start-VBRJob : Cannot bind parameter 'Job'. Cannot convert the "Jobname1" value
of type "System.String" to type "Veeam.Backup.Core.CBackupJob".
At line:1 char:18
+ start-vbrjob -job <<<<  'Jobname1'
    + CategoryInfo          : InvalidArgument: (:) [Start-VBRJob], ParameterBi
   ndingException
    + FullyQualifiedErrorId : CannotConvertArgumentNoMessage,Veeam.Backup.Powe
   rShell.Command.StartVBRJob
What is the accepted input to feed this cmdlet to start jobs?

cmbits
Lurker
Posts: 2
Liked: never
Joined: Mar 01, 2010 2:53 pm
Full Name: Chris Butler
Contact:

Re: Powershell script in v5

Post by cmbits » Oct 22, 2010 5:16 am

I am having the same problem. I've tried for 5 hours now to get the jobs running through powershell 2.0 with no luck. I'm wondering if there is a security context issue that didn't exist under the previous version of powershell?

Gostev
SVP, Product Management
Posts: 24169
Liked: 3295 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Powershell script in v5

Post by Gostev » Oct 22, 2010 7:32 am

Start-VBRJob and other cmdlets require job object to be specified, not name string (see page 165 of the User Guide).

Long version:

Code: Select all

$job = Get-VBRJob | where {$_.Name –eq “JobName1”}
Start-VBRJob –Job ($job)
Short version:

Code: Select all

Get-VBRJob | where {$_.Name –eq “JobName1”} | Start-VBRJob

chriswahl
Lurker
Posts: 2
Liked: never
Joined: Mar 08, 2010 12:51 am
Full Name: Chris Wahl

Re: Powershell script in v5

Post by chriswahl » Oct 22, 2010 2:57 pm

Works like a charm, thanks for providing the answer so quickly, Anton.

sprice
Lurker
Posts: 1
Liked: never
Joined: Nov 05, 2009 5:25 pm
Full Name: Simon Price
Contact:

Re: Powershell script in v5

Post by sprice » Jan 31, 2011 5:08 pm

Is it possible to use a similar command to retry a job?

Vitaliy S.
Product Manager
Posts: 22517
Liked: 1469 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Powershell script in v5

Post by Vitaliy S. » Jan 31, 2011 11:07 pm

Yes, that 's possible. If you want use an auto retry option, then this cmdlet example should help:

Code: Select all

$job = Get-VBRJob “JobName”

$s = $job.GetScheduleOptions()
$s.RetryTimes = 3
$s.OptionsDaily.Time = "22:00:51"
$job.SetScheduleOptions($s)

$job.Save()
If you start any job manually with Start-VBRJob, then you can use this for a retry operation:

Code: Select all

 Start-VBRJob JobName -RetryBackup 
Should work!

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests