I’m having challenges getting a job creation script to work for creating VM backup jobs. The code has a switch to create a VMWare/Hyper-V job based on provided input. The job is created without needed customizations in three areas (1) setting the schedule, (2) setting the retention policy, and (3) setting an encryption key on the backups. I haven’t gotten #3 in the code yet, but open to thoughts. After I run the script, it succeeds but the settings for #1 and #2 aren’t fully applied.
In the case of 1, the schedule is added but the job schedule isn’t enabled.
In the case of 2, nothing is enabled. I couldn’t find any other approach to do #2 except with a JobOptions object. Any ideas why not?
In the case of 3, I would use JobOptions if I could figure out for both but am contemplating just using Set-VBRAdvancedStorageOptions as that is straightforward.
#After Job Creation, the $Job variable is applied with the job it just created.
#$JobStartTime is created with Get-Date starting at 20:00
#Apply Settings
#Set schedule
$JobStartTime = $JobStartTime.AddHours(1)
Write-Verbose "Updating Schedule for job $Group with Start Time $($JobStartTime.Hour):00."
$Job = Set-VBRJobSchedule -Job $Job -Daily -At $JobStartTime -DailyKind Ever | Enable-VBRJobSchedule
#Add retention settings
$JobSettings = New-VBRJobOptions -ForBackupJob
$JobSettings.BackupStorageOptions.RetainDays = 3
$JobSettings.BackupStorageOptions.RetentionType = "Days"
#Add Encryption Settings
#Apply Settings
$Job = Set-VBRJobOptions -Job $Job -Options $JobSettings
The outcome is such as seen below: Note the retention policy is unchnaged, and the schedule is applied but not enabled.