Skip to content

Commit 2ab0e0e

Browse files
committed
fix: rerun issue
1 parent 8cd8d1d commit 2ab0e0e

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

Modules/CIPPCore/Public/Test-CIPPRerun.ps1

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ function Test-CIPPRerun {
6262
$NewSettings = $($Settings | ConvertTo-Json -Depth 10 -Compress)
6363
if ($NewSettings.Length -ne $PreviousSettings.Length) {
6464
Write-Host "$($NewSettings.Length) vs $($PreviousSettings.Length) - settings have changed."
65-
$RerunData.EstimatedNextRun = $EstimatedNextRun
66-
$RerunData.LastScheduledTime = "$CurrentUnixTime"
67-
$RerunData.Settings = "$($Settings | ConvertTo-Json -Depth 10 -Compress)"
65+
$RerunData | Add-Member -MemberType NoteProperty -Name 'EstimatedNextRun' -Value $EstimatedNextRun -Force
66+
$RerunData | Add-Member -MemberType NoteProperty -Name 'LastScheduledTime' -Value "$CurrentUnixTime" -Force
67+
$RerunData | Add-Member -MemberType NoteProperty -Name 'Settings' -Value "$($Settings | ConvertTo-Json -Depth 10 -Compress)" -Force
6868
Add-CIPPAzDataTableEntity @RerunTable -Entity $RerunData -Force
6969
return $false # Not a rerun because settings have changed.
7070
}
@@ -73,19 +73,19 @@ function Test-CIPPRerun {
7373
# treat it as a new execution rather than a duplicate.
7474
if ($BaseTime -gt 0 -and $RerunData.LastScheduledTime -and [int64]$RerunData.LastScheduledTime -ne $BaseTime) {
7575
Write-Information "Task $API has a new ScheduledTime ($BaseTime vs cached $($RerunData.LastScheduledTime)). Treating as new execution."
76-
$RerunData.EstimatedNextRun = $EstimatedNextRun
77-
$RerunData.LastScheduledTime = "$BaseTime"
78-
$RerunData.Settings = "$($Settings | ConvertTo-Json -Depth 10 -Compress)"
76+
$RerunData | Add-Member -MemberType NoteProperty -Name 'EstimatedNextRun' -Value $EstimatedNextRun -Force
77+
$RerunData | Add-Member -MemberType NoteProperty -Name 'LastScheduledTime' -Value "$BaseTime" -Force
78+
$RerunData | Add-Member -MemberType NoteProperty -Name 'Settings' -Value "$($Settings | ConvertTo-Json -Depth 10 -Compress)" -Force
7979
Add-CIPPAzDataTableEntity @RerunTable -Entity $RerunData -Force
8080
return $false
8181
}
8282
if ($RerunData.EstimatedNextRun -gt $CurrentUnixTime) {
8383
Write-LogMessage -API $API -message "$Type rerun detected for $($API). Prevented from running again." -tenant $TenantFilter -headers $Headers -Sev 'Info'
8484
return $true
8585
} else {
86-
$RerunData.EstimatedNextRun = $EstimatedNextRun
87-
$RerunData.LastScheduledTime = "$BaseTime"
88-
$RerunData.Settings = "$($Settings | ConvertTo-Json -Depth 10 -Compress)"
86+
$RerunData | Add-Member -MemberType NoteProperty -Name 'EstimatedNextRun' -Value $EstimatedNextRun -Force
87+
$RerunData | Add-Member -MemberType NoteProperty -Name 'LastScheduledTime' -Value "$BaseTime" -Force
88+
$RerunData | Add-Member -MemberType NoteProperty -Name 'Settings' -Value "$($Settings | ConvertTo-Json -Depth 10 -Compress)" -Force
8989
Add-CIPPAzDataTableEntity @RerunTable -Entity $RerunData -Force
9090
return $false
9191
}

0 commit comments

Comments
 (0)