You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
New-GraphPostRequest-uri 'https://graph.microsoft.com/v1.0/me/sendMail'-tenantid $env:TenantID-type POST -body $JSONBody
80
-
}
81
-
Write-LogMessage-API 'Alerts'-message "Sent $(($LogEmails|Measure-Object).Count) alerts to: $($Addresses-join', ')"-sev Debug
82
47
}
83
48
} catch {
84
49
Write-Information"Could not send alerts to email: $($_.Exception.message)"
@@ -89,35 +54,8 @@ function Push-SchedulerCIPPNotifications {
89
54
Write-Information$($config|ConvertTo-Json)
90
55
Write-Information$config.webhook
91
56
if ($Config.webhook-ne''-and$null-ne$CurrentLog) {
92
-
switch-wildcard ($config.webhook) {
93
-
94
-
'*webhook.office.com*' {
95
-
$Log=$Currentlog|ConvertTo-Html-frag |Out-String
96
-
$JSonBody="{`"text`": `"You've setup your alert policies to be alerted whenever specific events happen. We've found some of these events in the log. <br><br>$Log`"}"
97
-
Invoke-RestMethod-Uri $config.webhook-Method POST -ContentType 'Application/json'-Body $JSONBody
98
-
}
99
-
100
-
'*slack.com*' {
101
-
$Log=$Currentlog|ForEach-Object {
102
-
$JSonBody=@"
103
-
{"blocks":[{"type":"header","text":{"type":"plain_text","text":"New Alert from CIPP","emoji":true}},{"type":"section","fields":[{"type":"mrkdwn","text":"*DateTime:*\n$($_.Timestamp)"},{"type":"mrkdwn","text":"*Tenant:*\n$($_.Tenant)"},{"type":"mrkdwn","text":"*API:*\n$($_.API)"},{"type":"mrkdwn","text":"*User:*\n$($_.Username)."}]},{"type":"section","text":{"type":"mrkdwn","text":"*Message:*\n$($_.Message)"}}]}
104
-
"@
105
-
Invoke-RestMethod-Uri $config.webhook-Method POST -ContentType 'Application/json'-Body $JSONBody
106
-
}
107
-
}
108
-
109
-
'*discord.com*' {
110
-
$Log=$Currentlog|ConvertTo-Html-frag |Out-String
111
-
$JSonBody="{`"content`": `"You've setup your alert policies to be alerted whenever specific events happen. We've found some of these events in the log. $Log`"}"
112
-
Invoke-RestMethod-Uri $config.webhook-Method POST -ContentType 'Application/json'-Body $JSONBody
113
-
}
114
-
default {
115
-
$Log=$Currentlog|ConvertTo-Json-Compress
116
-
$JSonBody=$Log
117
-
Invoke-RestMethod-Uri $config.webhook-Method POST -ContentType 'Application/json'-Body $JSONBody
118
-
}
119
-
}
120
-
Write-LogMessage-API 'Alerts'-tenant $Tenant-message "Sent Webhook to $($config.webhook)"-sev Debug
0 commit comments