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 »

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 »

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
Chief Product Officer
Posts: 31707
Liked: 7212 times
Joined: Jan 01, 2006 1:01 am
Location: Baar, Switzerland
Contact:

Re: Powershell script in v5

Post by Gostev »

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 »

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 »

Is it possible to use a similar command to retry a job?
Vitaliy S.
VP, Product Management
Posts: 27325
Liked: 2778 times
Joined: Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov
Contact:

Re: Powershell script in v5

Post by Vitaliy S. »

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 4 guests