@@ -25,7 +25,7 @@ function Push-SchedulerCIPPNotifications {
25
25
$PartitionKey = Get-Date - UFormat ' %Y%m%d'
26
26
$Filter = " PartitionKey eq '{0}'" -f $PartitionKey
27
27
$Currentlog = Get-CIPPAzDataTableEntity @Table - Filter $Filter | Where-Object {
28
- $_.API -in $Settings -and $_.SentAsAlert -ne $true -and $_.Severity -in $severity
28
+ $_.API -in $Settings -and $_.sentAsAlert -ne $true -and $_.Severity -in $severity
29
29
}
30
30
$StandardsTable = Get-CIPPTable - tablename CippStandardsAlerts
31
31
$CurrentStandardsLogs = Get-CIPPAzDataTableEntity @StandardsTable - Filter $Filter | Where-Object {
@@ -50,12 +50,34 @@ function Push-SchedulerCIPPNotifications {
50
50
$Subject = " $ ( $Tenant ) : CIPP Alert: Alerts found starting at $ ( (Get-Date ).AddMinutes(-15 )) "
51
51
$HTMLContent = New-CIPPAlertTemplate - Data $Data - Format ' html' - InputObject ' table' - CIPPURL $CIPPURL
52
52
Send-CIPPAlert - Type ' email' - Title $Subject - HTMLContent $HTMLContent.htmlcontent - TenantFilter $tenant - APIName ' Alerts'
53
+ $UpdateLogs = $CurrentLog | ForEach-Object {
54
+ if ($_.PSObject.Properties.Name -contains ' sentAsAlert' ) {
55
+ $_.sentAsAlert = $true
56
+ } else {
57
+ $_ | Add-Member - MemberType NoteProperty - Name sentAsAlert - Value $true - Force
58
+ }
59
+ $_
60
+ }
61
+ if ($UpdateLogs ) {
62
+ Add-CIPPAzDataTableEntity @Table - Entity $UpdateLogs - Force
63
+ }
53
64
}
54
65
} else {
55
66
$Data = ($CurrentLog | Select-Object Message, API, Tenant, Username, Severity)
56
67
$Subject = " CIPP Alert: Alerts found starting at $ ( (Get-Date ).AddMinutes(-15 )) "
57
68
$HTMLContent = New-CIPPAlertTemplate - Data $Data - Format ' html' - InputObject ' table' - CIPPURL $CIPPURL
58
69
Send-CIPPAlert - Type ' email' - Title $Subject - HTMLContent $HTMLContent.htmlcontent - TenantFilter $tenant - APIName ' Alerts'
70
+ $UpdateLogs = $CurrentLog | ForEach-Object {
71
+ if ($_.PSObject.Properties.Name -contains ' sentAsAlert' ) {
72
+ $_.sentAsAlert = $true
73
+ } else {
74
+ $_ | Add-Member - MemberType NoteProperty - Name sentAsAlert - Value $true - Force
75
+ }
76
+ $_
77
+ }
78
+ if ($UpdateLogs ) {
79
+ Add-CIPPAzDataTableEntity @Table - Entity $UpdateLogs - Force
80
+ }
59
81
}
60
82
}
61
83
if ($CurrentStandardsLogs ) {
@@ -88,7 +110,7 @@ function Push-SchedulerCIPPNotifications {
88
110
if ($Currentlog ) {
89
111
$JSONContent = $Currentlog | ConvertTo-Json - Compress
90
112
Send-CIPPAlert - Type ' webhook' - JSONContent $JSONContent - TenantFilter $Tenant - APIName ' Alerts'
91
- $UpdateLogs = $CurrentLog | ForEach-Object { $_.SentAsAlert = $true ; $_ }
113
+ $UpdateLogs = $CurrentLog | ForEach-Object { $_.sentAsAlert = $true ; $_ }
92
114
if ($UpdateLogs ) { Add-CIPPAzDataTableEntity @Table - Entity $UpdateLogs - Force }
93
115
}
94
116
0 commit comments