PowerShell script exchange
Post Reply
jwz88
Influencer
Posts: 12
Liked: never
Joined: Sep 05, 2014 6:24 am
Contact:

Creating a backup job through powershell starts job directly

Post by jwz88 » Sep 05, 2014 6:38 am

Hi,

I created a simple script to create a backup job. When this gets created it directly starts the backup job.
I don't want this to happen, I want it to follow the schedule I submitted with the Job. Any tips?

Add-VBRViBackupJob -Name "$SERVERNAAM" -BackupRepository "Default Backup Repository" -Entity (Find-VBRViEntity -Server "192.168.20.75" -VMsAndTemplates -Name "$SERVERNAAM")
$Job = Get-VBRJob -Name "$SERVERNAAM"
$JobOptions = Get-VBRJobOptions $Job
$JobOptions.BackupTargetOptions.TransformFullToSyntethic = $false
$JobOptions.BackupStorageOptions.EnableFullBackup = $true
$JobOptions.BackupStorageOptions.RetainCycles = $SNAPSHOTS
Set-VBRJobOptions $Job -Options $JobOptions
$ScheduleOptions = Get-VBRJobScheduleOptions $Job
$ScheduleOptions.OptionsDaily.Enabled = $true
$ScheduleOptions.OptionsDaily.Kind = "Weekdays"
$ScheduleOptions.OptionsDaily.Time = "22:00:00"
Set-VBRJobScheduleOptions -Job ($Job) -Options ($ScheduleOptions)
Enable-VBRJobSchedule -Job ($Job)

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

Re: Creating a backup job through powershell starts job dire

Post by veremin » Sep 05, 2014 9:03 am

Can you tell me what time you can see if go to the job schedule settings right after the job has been created? Thanks.

jwz88
Influencer
Posts: 12
Liked: never
Joined: Sep 05, 2014 6:24 am
Contact:

Re: Creating a backup job through powershell starts job dire

Post by jwz88 » Sep 05, 2014 9:40 am

It shows on the main page:
<Scheduled>

after a few seconds this changes to: Next run, current time + 5 minutes.

When opening the job it shows the correct schedule.

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

Re: Creating a backup job through powershell starts job dire

Post by veremin » Sep 05, 2014 10:45 am

Hmm, what happens if you try to use slightly different syntax? Will it make any difference?

Code: Select all

$ScheduleOptions = $Job.GetScheduleOptions()
$ScheduleOptions.OptionsContinuous.Enabled = $false
$ScheduleOptions.OptionsMonthly.Enabled = $false
$ScheduleOptions.OptionsPeriodically.Enabled = $false
$ScheduleOptions.OptionsScheduleAfterJob.IsEnabled = $false
$ScheduleOptions.OptionsDaily.Enabled = $true
$ScheduleOptions.OptionsDaily.Kind = "Weekdays"
$ScheduleOptions.OptionsDaily.Time = "13:00:00"
Set-VBRJobScheduleOptions -Job ($Job) -Options ($ScheduleOptions)
I also assume you're on the latest product version, right?

Thanks.

jwz88
Influencer
Posts: 12
Liked: never
Joined: Sep 05, 2014 6:24 am
Contact:

Re: Creating a backup job through powershell starts job dire

Post by jwz88 » Sep 05, 2014 11:27 am

Same occurs. It adds the backup job and the next run is first set on <Scheduled>.
After a few seconds it changes to the current time + 5 minutes as next run time, while the schedule is for 22:00:00

Running on latest version, 7.0.0.871

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

Re: Creating a backup job through powershell starts job dire

Post by veremin » Sep 05, 2014 3:16 pm

We have number of issues related to schedule configuration working improperly in case of PS. So, this must be another instance of those. We're going to review it thoroughly and try to make sure that previous issues won't leak into the next product version. Thanks.

Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 2 guests