PowerShell script exchange
Post Reply
mickeybyte
Influencer
Posts: 10
Liked: 5 times
Joined: Apr 06, 2011 12:28 pm
Full Name: Michiel Peene
Contact:

set-vbrjoboptions disables job schedule

Post by mickeybyte »

Hi, I recently ran the script below to set custom notification options on my backup jobs. The notification options are set correctly, but the job schedule is disabled when running the script.
Before I run the script, in the GUI, the column "next run" shows the date/time when the job wil run next time. From the moment I run the script, the "next run" column changes to <not scheduled>. I have to go through the properties of the job and check the "run the job automatically" on the last screen to re-enable the schedule (I can't seem to find this option by using a powershell function)

Is this a bug or am I doing something wrong with my script?

Code: Select all

$options = New-VBRJobOptions -ForBackupJob
$options.NotificationOptions.SendEmailNotification2AdditionalAddresses = $true
$options.NotificationOptions.EmailNotificationAdditionalAddresses = "email@company.com"
$options.NotificationOptions.UseCustomEmailNotificationOptions = $true

$job = get-vbrjob -name "PBX"
Set-VBRJobOptions -job $job -Options $options
EDIT: It's even worse as I suspected, it also removes my Active Full settings and Syntethic Full settings. Before the script ran it was setup as "incremental, create synthetic full bakups on monday, create active full backups periodically, weekly on monday". After the script, create synthetic full is on saturday, create active full is unchcecked (I believe those are the default settings)
Veeam version is 9.5.4.2753
mickeybyte
Influencer
Posts: 10
Liked: 5 times
Joined: Apr 06, 2011 12:28 pm
Full Name: Michiel Peene
Contact:

Re: set-vbrjoboptions disables job schedule

Post by mickeybyte »

I think I'm getting an insight in this.
I create a new VBRJobOptions object, that is containing the defaults.
Then I change the notification options of that new object
Next I set the options of my job to the newly create $options object (containing the default settings except my changed notification settings)

So I think I have to first get the current options from my job, change the notification settings and set the options backup to my job.

Am I seeing it right now?

(Still I find it a dangerous thing that you can just mess up with the options so easily.)
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: set-vbrjoboptions disables job schedule

Post by jhoughes » 2 people like this post

You are correct, the New-VBRJobOptions cmdlet returns default job setting as documented:

"This cmdlet returns default job settings. You can edit any setting that you want to apply to a job."

For your desired changes, you need to get the existing job options, make your modifications, and then set those options.

The ability to create a new options object without needing to pull from an existing job if very powerful. It comes in very useful if you need some create something like a policy to apply to multiple jobs, and can then make minor adjustments to specific jobs.

It can be dangerous if you're not sure what action you are performing, or if you haven't read the documentation to confirm what the code should be doing.

When you are first starting out with scripting actions like this, I always suggest working with a new "test" job to see what happens, before making changes to production jobs.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
mickeybyte
Influencer
Posts: 10
Liked: 5 times
Joined: Apr 06, 2011 12:28 pm
Full Name: Michiel Peene
Contact:

Re: set-vbrjoboptions disables job schedule

Post by mickeybyte » 1 person likes this post

Did test it first on a single job, but never noticed the fact that all other options were reset to defaults...

In the end it's always the same: RTFM... :-)
jhoughes
Veeam Vanguard
Posts: 279
Liked: 112 times
Joined: Apr 20, 2017 4:19 pm
Full Name: Joe Houghes
Location: Castle Rock, CO
Contact:

Re: set-vbrjoboptions disables job schedule

Post by jhoughes »

Glad to hear you got it figured out, and without *too* much impact.
Husband, Father, Solutions Architect, Geek Extraordinaire | @DenverVMUG, @AustinVMUG & @ATXPowerShell leader | VMware vExpert | Cisco Champion
Post Reply

Who is online

Users browsing this forum: No registered users and 16 guests