File tree Expand file tree Collapse file tree
Entrypoints/Activity Triggers Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -51,6 +51,10 @@ function Add-CIPPScheduledTask {
5151 $task.Recurrence.value
5252 }
5353
54+ if ([int64 ]$task.ScheduledTime -eq 0 -or [string ]::IsNullOrEmpty($task.ScheduledTime )) {
55+ $task.ScheduledTime = [int64 ](([datetime ]::UtcNow) - (Get-Date ' 1/1/1970' )).TotalSeconds
56+ }
57+
5458 $entity = @ {
5559 PartitionKey = [string ]' ScheduledTask'
5660 TaskState = [string ]' Planned'
Original file line number Diff line number Diff line change @@ -100,6 +100,14 @@ function Push-ExecScheduledCommand {
100100 ' (\d+)d$' { [int64 ]$matches [1 ] * 86400 }
101101 default { throw " Unsupported recurrence format: $ ( $task.Recurrence ) " }
102102 }
103+
104+ if ($secondsToAdd -gt 0 ) {
105+ $unixtimeNow = [int64 ](([datetime ]::UtcNow) - (Get-Date ' 1/1/1970' )).TotalSeconds
106+ if ([int64 ]$task.ScheduledTime -lt ($unixtimeNow - $secondsToAdd )) {
107+ $task.ScheduledTime = $unixtimeNow
108+ }
109+ }
110+
103111 $nextRunUnixTime = [int64 ]$task.ScheduledTime + [int64 ]$secondsToAdd
104112 Write-Host " The job is recurring. It was scheduled for $ ( $task.ScheduledTime ) . The next runtime should be $nextRunUnixTime "
105113 Update-AzDataTableEntity @Table - Entity @ {
You can’t perform that action at this time.
0 commit comments