Skip to content

Commit e64def5

Browse files
Install-DbaMaintenanceSolution - Fix AutoScheduleJobs schedule bugs
- Fix HourlyLog creating daily-only schedule by adding FrequencySubDayType=Hours and FrequencySubDayInterval=1 - Fix null error when neither WeeklyFull nor DailyFull is specified by guarding New-DbaAgentSchedule @fullparams with a conditional Fixes #9051 (do Install-DbaMaintenanceSolution) Co-authored-by: Andreas Jordan <andreasjordan@users.noreply.github.com>
1 parent 97d03be commit e64def5

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

public/Install-DbaMaintenanceSolution.ps1

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,9 @@ function Install-DbaMaintenanceSolution {
636636
}
637637
}
638638

639-
$fullschedule = New-DbaAgentSchedule @fullparams
639+
if ("WeeklyFull" -in $AutoScheduleJobs -or "DailyFull" -in $AutoScheduleJobs) {
640+
$fullschedule = New-DbaAgentSchedule @fullparams
641+
}
640642

641643
if ($fullschedule.ActiveStartTimeOfDay) {
642644
$systemdaily = $fullschedule.ActiveStartTimeOfDay.Add($twohours) -replace ":|\-|1\.", ""
@@ -708,13 +710,15 @@ function Install-DbaMaintenanceSolution {
708710

709711
if ("HourlyLog" -in $AutoScheduleJobs) {
710712
$logparams = @{
711-
SqlInstance = $server
712-
Job = "DatabaseBackup - USER_DATABASES - LOG"
713-
Schedule = "Hourly Log Backup"
714-
FrequencyType = "Daily"
715-
FrequencyInterval = 1
716-
StartTime = "003000"
717-
Force = $true
713+
SqlInstance = $server
714+
Job = "DatabaseBackup - USER_DATABASES - LOG"
715+
Schedule = "Hourly Log Backup"
716+
FrequencyType = "Daily"
717+
FrequencyInterval = 1
718+
FrequencySubDayType = "Hours"
719+
FrequencySubDayInterval = 1
720+
StartTime = "000000"
721+
Force = $true
718722
}
719723
} else {
720724
$logparams = @{

0 commit comments

Comments
 (0)