@@ -36,8 +36,9 @@ function Push-CippDriftManagement {
3636
3737 $GenerateEmail = New-CIPPAlertTemplate - format ' html' - data $Data - CIPPURL $CIPPURL - Tenant $Item.Tenant - InputObject ' driftStandard' - AuditLogLink $drift.standardId
3838
39- # Send email alert if configured and not disabled
39+ # Check if notifications are disabled (default to false if not set)
4040 if (-not $Settings.driftAlertDisableEmail ) {
41+ # Send email alert if configured
4142 $CIPPAlert = @ {
4243 Type = ' email'
4344 Title = $GenerateEmail.title
@@ -46,33 +47,35 @@ function Push-CippDriftManagement {
4647 }
4748 Write-Information " Sending email alert for tenant $ ( $Item.Tenant ) "
4849 Send-CIPPAlert @CIPPAlert - altEmail $email
50+
51+ # Send webhook alert if configured
52+ $WebhookData = @ {
53+ Title = $GenerateEmail.title
54+ ActionUrl = $GenerateEmail.ButtonUrl
55+ ActionText = $GenerateEmail.ButtonText
56+ AlertData = $Data
57+ Tenant = $Item.Tenant
58+ } | ConvertTo-Json - Depth 5 - Compress
59+ $CippAlert = @ {
60+ Type = ' webhook'
61+ Title = $GenerateEmail.title
62+ JSONContent = $WebhookData
63+ TenantFilter = $Item.Tenant
64+ }
65+ Write-Information " Sending webhook alert for tenant $ ( $Item.Tenant ) "
66+ Send-CIPPAlert @CippAlert - altWebhook $webhook
67+
68+ # Send PSA alert
69+ $CIPPAlert = @ {
70+ Type = ' psa'
71+ Title = $GenerateEmail.title
72+ HTMLContent = $GenerateEmail.htmlcontent
73+ TenantFilter = $Item.Tenant
74+ }
75+ Send-CIPPAlert @CIPPAlert
4976 } else {
50- Write-Information " Email alert disabled for tenant $ ( $Item.Tenant ) "
51- }
52- # Send webhook alert if configured
53- $WebhookData = @ {
54- Title = $GenerateEmail.title
55- ActionUrl = $GenerateEmail.ButtonUrl
56- ActionText = $GenerateEmail.ButtonText
57- AlertData = $Data
58- Tenant = $Item.Tenant
59- } | ConvertTo-Json - Depth 5 - Compress
60- $CippAlert = @ {
61- Type = ' webhook'
62- Title = $GenerateEmail.title
63- JSONContent = $WebhookData
64- TenantFilter = $Item.Tenant
65- }
66- Write-Information " Sending webhook alert for tenant $ ( $Item.Tenant ) "
67- Send-CIPPAlert @CippAlert - altWebhook $webhook
68- # Always send PSA alert
69- $CIPPAlert = @ {
70- Type = ' psa'
71- Title = $GenerateEmail.title
72- HTMLContent = $GenerateEmail.htmlcontent
73- TenantFilter = $Item.Tenant
77+ Write-Information " All notifications disabled for tenant $ ( $Item.Tenant ) "
7478 }
75- Send-CIPPAlert @CIPPAlert
7679 return $true
7780 } else {
7881 Write-LogMessage - API ' DriftStandards' - tenant $Item.Tenant - message " No new drift deviations found for tenant $ ( $Item.Tenant ) " - sev Info
0 commit comments