Powershell script in v5

PowerShell script exchange

Powershell script in v5

Veeam Logoby chriswahl » Fri 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?
chriswahl
Lurker
 
Posts: 2
Liked: never
Joined: Mon Mar 08, 2010 12:51 am
Full Name: Chris Wahl

Re: Powershell script in v5

Veeam Logoby cmbits » Fri 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?
cmbits
Lurker
 
Posts: 2
Liked: never
Joined: Mon Mar 01, 2010 2:53 pm
Full Name: Chris Butler

Re: Powershell script in v5

Veeam Logoby Gostev » Fri 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
Gostev
Veeam Software
 
Posts: 21396
Liked: 2349 times
Joined: Sun Jan 01, 2006 1:01 am
Location: Baar, Switzerland

Re: Powershell script in v5

Veeam Logoby chriswahl » Fri Oct 22, 2010 2:57 pm

Works like a charm, thanks for providing the answer so quickly, Anton.
chriswahl
Lurker
 
Posts: 2
Liked: never
Joined: Mon Mar 08, 2010 12:51 am
Full Name: Chris Wahl

Re: Powershell script in v5

Veeam Logoby sprice » Mon Jan 31, 2011 5:08 pm

Is it possible to use a similar command to retry a job?
sprice
Lurker
 
Posts: 1
Liked: never
Joined: Thu Nov 05, 2009 5:25 pm
Full Name: Simon Price

Re: Powershell script in v5

Veeam Logoby Vitaliy S. » Mon 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!
Vitaliy S.
Veeam Software
 
Posts: 19564
Liked: 1104 times
Joined: Mon Mar 30, 2009 9:13 am
Full Name: Vitaliy Safarov


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 3 guests