Skip to content

Commit 57ad95c

Browse files
committed
Enhance alert comment handling in scheduled command
Alert comments now support dynamic %resultcount% replacement and tenant-based text replacement via Get-CIPPTextReplacement. Also, the alert box background color is set to transparent for improved UI consistency.
1 parent b805ce6 commit 57ad95c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Push-ExecScheduledCommand.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,12 @@ function Push-ExecScheduledCommand {
272272

273273
# Add alert comment if available
274274
if ($task.AlertComment) {
275-
$HTML += "<div style='background-color: #f8f9fa; border-left: 4px solid #007bff; padding: 15px; margin: 15px 0;'><h4 style='margin-top: 0; color: #007bff;'>Alert Information</h4><p style='margin-bottom: 0;'>$($task.AlertComment)</p></div>"
275+
if ($task.AlertComment -match '%resultcount%') {
276+
$resultCount = if ($Results -is [array]) { $Results.Count } else { 1 }
277+
$task.AlertComment = $task.AlertComment -replace '%resultcount%', "$resultCount"
278+
}
279+
$task.AlertComment = Get-CIPPTextReplacement -Text $task.AlertComment -TenantFilter $Tenant
280+
$HTML += "<div style='background-color: transparent; border-left: 4px solid #007bff; padding: 15px; margin: 15px 0;'><h4 style='margin-top: 0; color: #007bff;'>Alert Information</h4><p style='margin-bottom: 0;'>$($task.AlertComment)</p></div>"
276281
}
277282

278283
$title = "$TaskType - $Tenant - $($task.Name)"

0 commit comments

Comments
 (0)