PowerShell script exchange
Post Reply
PNWMtnBiker
Enthusiast
Posts: 63
Liked: 8 times
Joined: Jan 16, 2014 11:12 pm
Full Name: Jon Dufour
Contact:

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

Post by PNWMtnBiker »

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

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

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

Post by veremin »

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.
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
PNWMtnBiker
Enthusiast
Posts: 63
Liked: 8 times
Joined: Jan 16, 2014 11:12 pm
Full Name: Jon Dufour
Contact:

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

Post by PNWMtnBiker »

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

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

Post by PNWMtnBiker » 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
veremin
Product Manager
Posts: 20415
Liked: 2302 times
Joined: Oct 26, 2012 3:28 pm
Full Name: Vladimir Eremin
Contact:

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

Post by veremin »

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.
Post Reply

Who is online

Users browsing this forum: No registered users and 12 guests