PowerShell script exchange
Post Reply
JRRW
Enthusiast
Posts: 82
Liked: 49 times
Joined: Dec 10, 2019 3:59 pm
Full Name: Ryan Walker
Contact:

Powershell scheduling options

Post by JRRW »

Quick aside: Veeam needs to make a better powershell module. The syntax, and the limitations are significant and annoying. Compared to any other sort of powershell module I've worked with, Veeam's is utterly frustrating.

Case in point: Job schedules
I want to copy the job schedule - specifically the hours it's allowed to run - from one job and apply to multiple others.

Though it's something I can do in the UI, it's far faster to use a command when there's more or less a copy/paste.

This KB vaguely goes into how this might be done, but it's seriously lacking in logic.

If someone knows, I'd love to understand how I can do this specific command:
  • Enable jobs ALL DAY Sunday-Friday
  • Enable Saturday only 00:00-18:00
But, there's seemingly no way to do this - if you do a fromday today of Sunday / Friday you can do 00 to 00 but you can't then put only 00 to 18 for Saturday...

I even asked an LLM to try and figure it out, and unsurprisingly it made up options that made far more sense (saving a current jobs options via $options=Get-VBRJob -Name "vbrname" | Get-VBRJobScheduleOptions | select OptionsPeriodically and then do a set-vbrjobscheduleoptions -options $options) but it straight up doesn't work that way, even though you can 'get' the data, and there's a 'set' option, you can't get/set the same things... The LLMs all thought it would make sense, but that's not how Veeam apparently coded their powershell =(

Hopefully I'm just not understanding this, and it's doable!
david.domask
Veeam Software
Posts: 2838
Liked: 650 times
Joined: Jun 28, 2016 12:12 pm
Contact:

Re: Powershell scheduling options

Post by david.domask »

Hi Ryan,

New-VBRScheduleOptions indeed is not the most glamorous tool, will try to think of ways to handle this a bit better as the only way I can think to pass a fairly custom schedule is editing the resulting VBRBackupWindowsOption object directly; each set of 24 characters represents a day, but that is absolutely tedious to edit even with a decent function for it.

For your immediate need, you should be able to work with just CJob objects, as they have the Backup Window under a property $_.ScheduleOptions.OptionsBackupWindow

There are two properties underneath this, IsEnabled (boolean) and some XML for the actual backup window.

Use Set-VBRJobScheduleOptions to enable the schedule as normal, and to enable the backup window, use this workaround (variable names just for reading convenience):

Code: Select all

$donorJob = Get-VBRJob -Name "source job with backup window you want"
$job2Change = Get-VBRJob -Name "name of job you want to set backup window on"
$donorBWindow = $donorJob.ScheduleOptions.OptionsBackupWindow.BackupWindow
$job2Change.ScheduleOptions.OptionsBackupWindow.IsEnabled = $true
$job2Change.ScheduleOptions.OptionsBackupWIndow.BackupWindow = $donorBWindow
$job2Change.Update()
You can just loop over each job you want to change this way. It's an unsupported method, but I think this will be cleanest for you and it's only "a little" unsupported.
David Domask | Product Management: Principal Analyst
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest