File tree Expand file tree Collapse file tree 1 file changed +11
-1
lines changed
Modules/CIPPCore/Public/Entrypoints/Activity Triggers Expand file tree Collapse file tree 1 file changed +11
-1
lines changed Original file line number Diff line number Diff line change @@ -18,6 +18,16 @@ function Push-ExecScheduledCommand {
1818 # We don't need to expand groups here as that's handled in the orchestrator
1919 $TenantInfo = Get-Tenants - TenantFilter $Tenant
2020
21+ $CurrentTask = Get-AzDataTableEntity @Table - Filter " PartitionKey eq '$ ( $task.PartitionKey ) ' and RowKey eq '$ ( $task.RowKey ) '"
22+ if (! $CurrentTask ) {
23+ Write-Information " The task $ ( $task.Name ) for tenant $ ( $task.Tenant ) does not exist in the ScheduledTasks table. Exiting."
24+ return
25+ }
26+ if ($CurrentTask.TaskState -eq ' Completed' ) {
27+ Write-Information " The task $ ( $task.Name ) for tenant $ ( $task.Tenant ) is already completed. Skipping execution."
28+ return
29+ }
30+
2131 if ($task.Trigger ) {
2232 # Extract trigger data from the task and process
2333 $Trigger = if (Test-Json - Json $task.Trigger ) { $task.Trigger | ConvertFrom-Json } else { $task.Trigger }
@@ -276,7 +286,7 @@ function Push-ExecScheduledCommand {
276286 Write-Information ' Sent the results to the target. Updating the task state.'
277287
278288 try {
279- if ($task.Recurrence -eq ' 0' -or [string ]::IsNullOrEmpty($task.Recurrence ) -or $Trigger.ExecutionMode.value -eq ' once' ) {
289+ if ($task.Recurrence -eq ' 0' -or [string ]::IsNullOrEmpty($task.Recurrence ) -or $Trigger.ExecutionMode.value -eq ' once' -or $Trigger .ExecutionMode -eq ' once ' ) {
280290 Write-Information ' Recurrence empty or 0. Task is not recurring. Setting task state to completed.'
281291 Update-AzDataTableEntity - Force @Table - Entity @ {
282292 PartitionKey = $task.PartitionKey
You can’t perform that action at this time.
0 commit comments