PowerShell script exchange
sidavid
Enthusiast
Posts: 48 Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:
Post
by sidavid » Oct 18, 2018 1:17 am
this post
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: 8191 Liked: 1322 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:
Post
by Mike Resseler » Oct 22, 2018 6:52 am
this post
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: 48 Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:
Post
by sidavid » Oct 22, 2018 12:16 pm
this post
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: 8191 Liked: 1322 times
Joined: Feb 08, 2013 3:08 pm
Full Name: Mike Resseler
Location: Belgium
Contact:
Post
by Mike Resseler » Oct 23, 2018 4:06 am
this post
Not sure if I understand it now. Did it work now?
sidavid
Enthusiast
Posts: 48 Liked: 1 time
Joined: Jan 01, 2006 1:01 am
Contact:
Post
by sidavid » Oct 23, 2018 11:33 am
1 person likes this post
Yes perfectly !!! Exactly what I want to do
akashUniyal
Novice
Posts: 3 Liked: never
Joined: Jan 05, 2024 10:27 am
Full Name: Akash Uniyal
Contact:
Post
by akashUniyal » Feb 29, 2024 11:10 am
this post
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
Veeam Software
Posts: 2123 Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:
Post
by david.domask » Feb 29, 2024 1:24 pm
this post
Hi
@akashUniyal ,
Pass the CJob object returned by Get-VBRJob to
Enable-VBRJobSchedule . That will set the Run Automatically value.
David Domask | Product Management: Principal Analyst
akashUniyal
Novice
Posts: 3 Liked: never
Joined: Jan 05, 2024 10:27 am
Full Name: Akash Uniyal
Contact:
Post
by akashUniyal » Feb 29, 2024 4:19 pm
this post
Hi David,
Thanks a lot for the help.
david.domask
Veeam Software
Posts: 2123 Liked: 513 times
Joined: Jun 28, 2016 12:12 pm
Contact:
Post
by david.domask » Mar 01, 2024 10:19 am
this post
Always welcome good luck with the scripting!
David Domask | Product Management: Principal Analyst
Users browsing this forum: No registered users and 13 guests