PowerShell script exchange
Post Reply
sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Set Run the job automatically

Post by sidavid »

Hi All,

I tried since several hours to make that works but I can not find a script that do what I need.

I want to set in A Veeam Backup job/Schedule/Set the Run the job automatically, Daily at this time, 5:00 PM Everyday

Code: Select all

Get-VBRJob -Name "NameOfTheJob" | foreach {
Write-Host $_.Name
$Job = Get-VBRJob -Name $_.Name
$Time = "17:00:00"	

	$JobScheduleOptions = $Job | Get-VBRJobScheduleOptions
		$JobScheduleOptions.OptionsDaily.Enabled = $true
		$JobScheduleOptions.OptionsDaily.Kind = "Everyday"
		$JobScheduleOptions.OptionsDaily.Time = $Time
		$JobScheduleOptions.NextRun = $Time
		$JobScheduleOptions.StartDateTime = $Time
	$Job | Set-VBRJobScheduleOptions -Options $JobScheduleOptions
	$Job.EnableScheduler()	
}
I tried the above sample but this doesn't work at all.

Thanks for your lights

DS
Mike Resseler
Product Manager
Posts: 8044
Liked: 1263 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Set Run the job automatically

Post by Mike Resseler »

Hi DS,

I think you need to do it like this:

Code: Select all

$JobScheduleOptions = New-VBRJobScheduleOptions
$JobScheduleOptions.OptionsDaily.Enabled = $true
		$JobScheduleOptions.OptionsDaily.Kind = "Everyday"
		$JobScheduleOptions.OptionsDaily.Time = $Time
		$JobScheduleOptions.NextRun = $Time
		$JobScheduleOptions.StartDateTime = $Time
$Job | Set-VBRJobScheduleOptions -Options $JobScheduleOptions
With the line $JobScheduleOptions = $Job | Get-VBRJobScheduleOptions, you retrieve the existing settings of the job. I removed it and changed the line with $JobScheduleOptions = New-VBRJobScheduleOptions whcih creates new schedule settings. After you have created those, you apply them by using Set-VBRJobScheduleOptions. Don't worry if there are already scheduling options which you don't want to change. Each parameter you omit will remain unchanged
sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: Set Run the job automatically

Post by sidavid »

Hi

I managed that differentially

Code: Select all

Get-VBRJob -Name "NameOfJob" | Set-VBRJobSchedule -Daily -At "17:00" -DailyKind Everyday
Thanks
Mike Resseler
Product Manager
Posts: 8044
Liked: 1263 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:

Re: Set Run the job automatically

Post by Mike Resseler »

Not sure if I understand it now. Did it work now?
sidavid
Enthusiast
Posts: 63
Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:

Re: Set Run the job automatically

Post by sidavid » 1 person likes this post

Yes perfectly !!! Exactly what I want to do
akashUniyal
Lurker
Posts: 2
Liked: never
Joined: Jan 05, 2024 10:27 am
Full Name: Akash Uniyal
Contact:

Re: Set Run the job automatically

Post by akashUniyal »

Hi,

I'm trying to achieve that all my jobs created using script will run automatically. I'm trying to run "Set-VBRJobSchedule -Job (Get-VBRJob | ?{$_.Name -eq $JobName}) -Daily -At 21:00 -DailyKind Everyday", what this is doing is it sets my next run schedule for 21:00 but it doesn't checks the option Run the job automatically.
david.domask
VeeaMVP
Posts: 1034
Liked: 278 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Set Run the job automatically

Post by david.domask »

Hi @akashUniyal,

Pass the CJob object returned by Get-VBRJob to Enable-VBRJobSchedule. That will set the Run Automatically value.
David Domask | Director: Customer Care | Veeam Technical Support
akashUniyal
Lurker
Posts: 2
Liked: never
Joined: Jan 05, 2024 10:27 am
Full Name: Akash Uniyal
Contact:

Re: Set Run the job automatically

Post by akashUniyal »

Hi David,

Thanks a lot for the help.
david.domask
VeeaMVP
Posts: 1034
Liked: 278 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Set Run the job automatically

Post by david.domask »

Always welcome good luck with the scripting!
David Domask | Director: Customer Care | Veeam Technical Support
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests