Skip to content

Commit b1ee80a

Browse files
authored
Merge pull request #614 from KelvinTegelaar/dev
[pull] dev from KelvinTegelaar:dev
2 parents 1316eb1 + dacfb38 commit b1ee80a

File tree

2 files changed

+30
-33
lines changed

2 files changed

+30
-33
lines changed

Modules/CIPPCore/Public/Entrypoints/Activity Triggers/Standards/Push-CIPPDriftManagement.ps1

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Identity/Administration/Users/Invoke-ListNewUserDefaults.ps1

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ function Invoke-ListNewUserDefaults {
1212

1313
# Get the TenantFilter from query parameters
1414
$TenantFilter = $Request.Query.TenantFilter
15-
Write-Host "TenantFilter from request: $TenantFilter"
16-
15+
1716
# Get the includeAllTenants flag from query or body parameters (defaults to true)
1817
$IncludeAllTenants = if ($Request.Query.includeAllTenants -eq 'false' -or $Request.Body.includeAllTenants -eq 'false') {
1918
$false
2019
} else {
2120
$true
2221
}
23-
Write-Host "IncludeAllTenants: $IncludeAllTenants"
2422

2523
# Get the templates table
2624
$Table = Get-CippTable -tablename 'templates'
@@ -33,15 +31,12 @@ function Invoke-ListNewUserDefaults {
3331
$data = $row.JSON | ConvertFrom-Json -Depth 100 -ErrorAction Stop
3432
$data | Add-Member -NotePropertyName 'GUID' -NotePropertyValue $row.GUID -Force
3533
$data | Add-Member -NotePropertyName 'RowKey' -NotePropertyValue $row.RowKey -Force
36-
Write-Host "Template found: $($data.templateName), tenantFilter: $($data.tenantFilter)"
3734
$data
3835
} catch {
3936
Write-Warning "Failed to process User Default template: $($row.RowKey) - $($_.Exception.Message)"
4037
}
4138
}
4239

43-
Write-Host "Total templates before filtering: $($Templates.Count)"
44-
4540
# Filter by tenant if TenantFilter is provided
4641
if ($TenantFilter) {
4742
if ($TenantFilter -eq 'AllTenants') {
@@ -57,7 +52,6 @@ function Invoke-ListNewUserDefaults {
5752
$Templates = $Templates | Where-Object -Property tenantFilter -eq $TenantFilter
5853
}
5954
}
60-
Write-Host "Templates after filtering: $($Templates.Count)"
6155
}
6256

6357
# Sort by template name

0 commit comments

Comments
 (0)