Skip to content

Commit 9b53353

Browse files
committed
fix issue loading scheduler with corrupt data
1 parent a851931 commit 9b53353

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/CIPP/Scheduler/Invoke-ListScheduledItems.ps1

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,18 @@ function Invoke-ListScheduledItems {
6161
$Tasks = $Tasks | Where-Object -Property Tenant -In $AllowedTenantDomains
6262
}
6363
$ScheduledTasks = foreach ($Task in $tasks) {
64+
if (!$Task.Tenant -or !$Task.Command) {
65+
continue
66+
}
67+
6468
if ($Task.Parameters) {
6569
$Task.Parameters = $Task.Parameters | ConvertFrom-Json -ErrorAction SilentlyContinue
6670
} else {
6771
$Task | Add-Member -NotePropertyName Parameters -NotePropertyValue @{}
6872
}
69-
if ($Task.Recurrence -eq 0 -or [string]::IsNullOrEmpty($Task.Recurrence)) {
73+
if (!$Task.Recurrence) {
74+
$Task | Add-Member -NotePropertyName Recurrence -NotePropertyValue 'Once' -Force
75+
} elseif ($Task.Recurrence -eq 0 -or [string]::IsNullOrEmpty($Task.Recurrence)) {
7076
$Task.Recurrence = 'Once'
7177
}
7278
try {

0 commit comments

Comments
 (0)