@@ -487,53 +487,6 @@ function Receive-CIPPTimerTrigger {
487487
488488 $UtcNow = (Get-Date ).ToUniversalTime()
489489
490- try {
491- # temporary orphan check - Remove at next release.
492- $OrphanConfigTable = Get-CIPPTable - tablename ' Config'
493- $OrphanFlag = Get-CIPPAzDataTableEntity @OrphanConfigTable - Filter " PartitionKey eq 'OrphanRequeue' and RowKey eq 'OrphanRequeue'" - ErrorAction SilentlyContinue
494- if (-not $OrphanFlag -or $OrphanFlag.state -ne $true ) {
495- $OrchestratorTable = Get-CIPPTable - TableName ' CippOrchestratorInput'
496- $OrphanedInputs = Get-CIPPAzDataTableEntity @OrchestratorTable - Filter " PartitionKey eq 'Input'"
497- $CutoffTime = $UtcNow.AddMinutes (-5 )
498- $MaxAge = $UtcNow.AddHours (-24 )
499- $StaleOrphans = @ ($OrphanedInputs | Where-Object { $_.Timestamp.DateTime -lt $CutoffTime -and $_.Timestamp.DateTime -gt $MaxAge })
500- if ($StaleOrphans.Count -gt 0 ) {
501- Write-Information " Found $ ( $StaleOrphans.Count ) orphaned orchestration inputs, re-queuing..."
502- foreach ($Orphan in $StaleOrphans ) {
503- try {
504- Add-CippQueueMessage - Cmdlet ' Start-CIPPOrchestrator' - Parameters @ { InputObjectGuid = $Orphan.RowKey }
505- Write-Information " Re-queued orphaned orchestration: $ ( $Orphan.RowKey ) "
506- } catch {
507- Write-Warning " Failed to re-queue orphan $ ( $Orphan.RowKey ) : $ ( $_.Exception.Message ) "
508- }
509- }
510- Write-LogMessage - API ' TimerFunction' - message " Re-queued $ ( $StaleOrphans.Count ) orphaned orchestration inputs" - sev Info
511- }
512- # Clean up orphans older than 24h - too stale to run
513- $ExpiredOrphans = @ ($OrphanedInputs | Where-Object { $_.Timestamp.DateTime -le $MaxAge })
514- if ($ExpiredOrphans.Count -gt 0 ) {
515- Write-Information " Removing $ ( $ExpiredOrphans.Count ) expired orphaned inputs (older than 24h)..."
516- foreach ($Expired in $ExpiredOrphans ) {
517- try {
518- Remove-AzDataTableEntity @OrchestratorTable - Entity $Expired - Force
519- } catch {
520- Write-Warning " Failed to remove expired orphan $ ( $Expired.RowKey ) : $ ( $_.Exception.Message ) "
521- }
522- }
523- }
524- # Mark as completed so we don't scan again
525- $null = Add-CIPPAzDataTableEntity @OrphanConfigTable - Entity @ {
526- PartitionKey = ' OrphanRequeue'
527- RowKey = ' OrphanRequeue'
528- state = $true
529- Timestamp = $UtcNow
530- Count = $StaleOrphans.Count
531- } - Force
532- }
533- } catch {
534- Write-Warning " Orphan re-queue check failed: $ ( $_.Exception.Message ) "
535- }
536-
537490 $Functions = Get-CIPPTimerFunctions
538491 $Table = Get-CIPPTable - tablename CIPPTimers
539492 $Statuses = Get-CIPPAzDataTableEntity @Table
0 commit comments