From a50357ee13c4ffc94eaa0892d132b1d45c41ad7a Mon Sep 17 00:00:00 2001 From: andreasjordan Date: Mon, 10 Jun 2024 16:45:32 +0200 Subject: [PATCH 1/2] Refactoring (do New-DbaAgentSchedule) --- public/New-DbaAgentSchedule.ps1 | 89 ++++++++++++++------------------- 1 file changed, 37 insertions(+), 52 deletions(-) diff --git a/public/New-DbaAgentSchedule.ps1 b/public/New-DbaAgentSchedule.ps1 index 16f7f917a0..6352080fd3 100644 --- a/public/New-DbaAgentSchedule.ps1 +++ b/public/New-DbaAgentSchedule.ps1 @@ -76,28 +76,28 @@ function New-DbaAgentSchedule { FrequencyRecurrenceFactor is used only if FrequencyType is "Weekly", "Monthly" or "MonthlyRelative". .PARAMETER StartDate - The date on which execution of a job can begin. + The date on which execution of a job can begin. Must be a string in the format yyyyMMdd. If force is used the start date will be the current day .PARAMETER EndDate - The date on which execution of a job can stop. + The date on which execution of a job can stop. Must be a string in the format yyyyMMdd. - If force is used the end date will be '9999-12-31' + If force is used the end date will be '99991231' .PARAMETER StartTime - The time on any day to begin execution of a job. Format HHMMSS / 24 hour clock. + The time on any day to begin execution of a job. Must be a string in the format HHmmss / 24 hour clock. Example: '010000' for 01:00:00 AM. Example: '140000' for 02:00:00 PM. - If force is used the start time will be '00:00:00' + If force is used the start time will be '000000' for midnight. .PARAMETER EndTime - The time on any day to end execution of a job. Format HHMMSS / 24 hour clock. + The time on any day to end execution of a job. Must be a string in the format HHmmss / 24 hour clock. Example: '010000' for 01:00:00 AM. Example: '140000' for 02:00:00 PM. - If force is used the start time will be '23:59:59' + If force is used the end time will be '235959' for one second before midnight. .PARAMETER Owner Login to own the job, defaults to login running the command. @@ -379,10 +379,6 @@ function New-DbaAgentSchedule { } } - # Setup the regex - $RegexDate = '(? Date: Fri, 14 Jun 2024 15:05:17 +0200 Subject: [PATCH 2/2] fix (do New-DbaAgentSchedule) --- public/New-DbaAgentSchedule.ps1 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/public/New-DbaAgentSchedule.ps1 b/public/New-DbaAgentSchedule.ps1 index 6352080fd3..f247525eb0 100644 --- a/public/New-DbaAgentSchedule.ps1 +++ b/public/New-DbaAgentSchedule.ps1 @@ -422,7 +422,7 @@ function New-DbaAgentSchedule { return } try { - $activeStartTimeOfDay = New-Object System.TimeSpan($StartTime.Substring(0, 2), $StartTime.Substring(2, 2), $StartTime.Substring(2, 2)) + $activeStartTimeOfDay = New-Object System.TimeSpan($StartTime.Substring(0, 2), $StartTime.Substring(2, 2), $StartTime.Substring(4, 2)) } catch { Stop-Function -Message "Start time $StartTime needs to be a valid time with format HHmmss." -Target $SqlInstance return @@ -437,7 +437,7 @@ function New-DbaAgentSchedule { return } try { - $activeEndTimeOfDay = New-Object System.TimeSpan($EndTime.Substring(0, 2), $EndTime.Substring(2, 2), $EndTime.Substring(2, 2)) + $activeEndTimeOfDay = New-Object System.TimeSpan($EndTime.Substring(0, 2), $EndTime.Substring(2, 2), $EndTime.Substring(4, 2)) } catch { Stop-Function -Message "End time $EndTime needs to be a valid time with format HHmmss." -Target $SqlInstance return