Setting the backup job schedule works yet doesn't work V7

PowerShell script exchange

Setting the backup job schedule works yet doesn't work V7

Veeam Logoby PNWMtnBiker » Thu Feb 20, 2014 5:20 pm

I am working on a powershell script to change the schedule of the jobs in the array. The script works and when looking at the job in the GUI the schedule reflects what's shown in the script. Then when I enable the job the schedule defaults to that 10:00 time instead. Anyone else experience this? This is Version 7 R2.

Code: Select all
   
$Array = "Job1","Job2","Job3"
   
    foreach ($_ in $Array)
        {
        Get-VBRJob -Name "$_" | Set-VBRJobSchedule -Daily -At "18:30" -DailyKind Everyday
        Get-VBRJob -Name "$_" | Enable-VBRJobSchedule

        }
PNWMtnBiker
Enthusiast
 
Posts: 63
Liked: 8 times
Joined: Thu Jan 16, 2014 11:12 pm
Full Name: Jon Dufour

Re: Setting the backup job schedule works yet doesn't work V

Veeam Logoby v.Eremin » Fri Feb 21, 2014 3:19 pm

I have just tried the provided script. You were right, it doesn't seem to work properly. Even though the time is updated rightly in the job settings, it isn't reflected well in GUI ("Next run").

Let me check this behavior more closely, and update the topic, once I have more information.

Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Setting the backup job schedule works yet doesn't work V

Veeam Logoby v.Eremin » Fri Feb 21, 2014 4:00 pm

After playing around with PS snap-in a little bit, I think, I found the solution. Try the following script and see whether it sets the right schedule time for the given job:

Code: Select all
asnp VeeamPSSnapin

$ScheduleOptions = New-VBRJobScheduleOptions

$Job = Get-VBRJob -name "Name of your backup job"


$ScheduleOptions.OptionsContinuous.Enabled = $False
$ScheduleOptions.OptionsMonthly.Enabled = $False
$ScheduleOptions.OptionsScheduleAfterJob.IsEnabled = $False
$ScheduleOptions.OptionsPeriodically.Enabled = $False

$Date = Get-Date -Hour 18 -Minute 30

$ScheduleOptions.StartDateTime = $Date
$ScheduleOptions.OptionsDaily.Enabled = $True
$ScheduleOptions.OptionsDaily.Kind = "Everyday"
$ScheduleOptions.OptionsDaily.Time = $Date

$Options = $Job.GetOptions()
$Options.JobOptions.RunManually = $False
$Job.SetOptions($Options)

Set-VBRJobScheduleOptions -Job $Job -Options $ScheduleOptions


Hope this helps.
Thanks.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin

Re: Setting the backup job schedule works yet doesn't work V

Veeam Logoby PNWMtnBiker » Fri Feb 21, 2014 7:56 pm

Thanks v.Eremin! I'll give this a try after lunch and get back to you.
PNWMtnBiker
Enthusiast
 
Posts: 63
Liked: 8 times
Joined: Thu Jan 16, 2014 11:12 pm
Full Name: Jon Dufour

Re: Setting the backup job schedule works yet doesn't work V

Veeam Logoby PNWMtnBiker » Sat Feb 22, 2014 4:01 am 1 person likes this post

I finally got a moment to try this and it worked perfectly, thank you very much. I was able to easily turn it into a loop and set them all.

Here's what I did so that someone can use it if need be.

I prefix all my primary jobs with HSB which identifies the repository location for me. Leave that out to get all your jobs or change it to identify just what you want to change.

Code: Select all
asnp VeeamPSSnapin

$array = get-vbrjob -name *HSB* | foreach{$_.name}

foreach($_ in $array)
    {

    $ScheduleOptions = New-VBRJobScheduleOptions

    $Job = Get-VBRJob -name "$_"

    $ScheduleOptions.OptionsContinuous.Enabled = $False
    $ScheduleOptions.OptionsMonthly.Enabled = $False
    $ScheduleOptions.OptionsScheduleAfterJob.IsEnabled = $False
    $ScheduleOptions.OptionsPeriodically.Enabled = $False

    $Date = Get-Date -Hour 18 -Minute 30

    $ScheduleOptions.StartDateTime = $Date
    $ScheduleOptions.OptionsDaily.Enabled = $True
    $ScheduleOptions.OptionsDaily.Kind = "Everyday"
    $ScheduleOptions.OptionsDaily.Time = $Date

    $Options = $Job.GetOptions()
    $Options.JobOptions.RunManually = $False
    $Job.SetOptions($Options)

    Set-VBRJobScheduleOptions -Job $Job -Options $ScheduleOptions

    }


Thank you again for your help :D
PNWMtnBiker
Enthusiast
 
Posts: 63
Liked: 8 times
Joined: Thu Jan 16, 2014 11:12 pm
Full Name: Jon Dufour

Re: Setting the backup job schedule works yet doesn't work V

Veeam Logoby v.Eremin » Sat Feb 22, 2014 8:40 am

Thank you again for raising this, we will take a closer look at why existing commandlets don't work as expected.

At least, for now you have an alternative script that you can use.

Should any other question arise, don't hesitate to let me know.
v.Eremin
Veeam Software
 
Posts: 13266
Liked: 968 times
Joined: Fri Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin


Return to PowerShell



Who is online

Users browsing this forum: No registered users and 5 guests