From 11aa107411f965dd1701c78d57471c41f6782881 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9on?= Date: Mon, 18 Nov 2024 01:29:53 +0100 Subject: [PATCH] Write failedPolicyRemediationTasksJsonString and createWorkItem on Failed to Create Remediation (#821) * updated condition for setting ceateWorkItem to true * remove additional space * removed duplicate (-not $Interactive) statement --- Scripts/Operations/New-AzRemediationTasks.ps1 | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Scripts/Operations/New-AzRemediationTasks.ps1 b/Scripts/Operations/New-AzRemediationTasks.ps1 index e5f28d48..84ea3bf9 100644 --- a/Scripts/Operations/New-AzRemediationTasks.ps1 +++ b/Scripts/Operations/New-AzRemediationTasks.ps1 @@ -384,11 +384,6 @@ else { Write-Information "$succeeded succeeded" if ($failed -gt 0) { Write-Information "$failed failed" - if (-not $Interactive) { - $failedPolicyRemediationTasksJsonString = $failedPolicyRemediationTasks | ConvertTo-Json -Depth 10 -Compress - Write-Output "##vso[task.setvariable variable=failedPolicyRemediationTasksJsonString;isOutput=true]$($failedPolicyRemediationTasksJsonString)" - $createWorkItem = $true - } } if ($canceled -gt 0) { Write-Information "$canceled canceled" @@ -397,6 +392,12 @@ else { Write-Information "$stillRunning still running after $checkForMinutes minutes" } if (-not $Interactive) { + if (($failed -gt 0) -or ($failedToCreate -gt 0)) { + $failedPolicyRemediationTasksJsonString = $failedPolicyRemediationTasks | ConvertTo-Json -Depth 10 -Compress + Write-Output "##vso[task.setvariable variable=failedPolicyRemediationTasksJsonString;isOutput=true]$($failedPolicyRemediationTasksJsonString)" + $createWorkItem = $true + } + Write-Output "##vso[task.setvariable variable=createWorkItem;isOutput=true]$($createWorkItem)" } }