#
Microsoft Teams notifications
Submitted by Insane Technologies / David Rudduck
requires
- agent {{agent.hostname}}
- client {{client.name}}
- site {{site.name}}
- user {{agent.logged_in_user}}
- reboot {{agent.needs_reboot}}
- patches {{agent.patches_last_installed}}
- alert_time {{alert.alert_time}}
- message {{alert.message}}
- severity {{alert.severity}}
#>
param (
[string] $agent,
[string] $client,
[string] $site,
[string] $user,
[string] $reboot,
[string] $patches,
[string] $time,
[string] $message,
[string] $severity
)
$webhookurl = 'ADDYOURMSTEAMSWEBHOOKURLHERE'
if($severity -eq "error"){
$colour = 'ff0000'
}
if($severity -eq "warning"){
$color = 'ffa500'
}
if($severity -eq "info"){
$colour = 'ffff00'
}
$msteams_payload = '{"@context": "https://schema.org/extensions", "@type": "MessageCard", "summary": "TacticalRMM Alert", "themeColor": "' + $colour +'", '
$msteams_payload = $msteams_payload + '"text": "'
if($time) {
$msteams_payload = $msteams_payload + 'Alert Time: ' + $time +'
'
}
$msteams_payload = $msteams_payload + 'Client: ' + $client +'
'
$msteams_payload = $msteams_payload + 'Site: ' + $site +'
'
$msteams_payload = $msteams_payload + 'Device: ' + $agent +'
'
if($user) {
$msteams_payload = $msteams_payload + 'User: ' + $user +'
'
}
if($reboot) {
$msteams_payload = $msteams_payload + 'Device has pending reboot
'
}
if($patches) {
$msteams_payload = $msteams_payload + 'Patches were last applied: ' + $patches +'
'
}
$msteams_payload = $msteams_payload + $message + '"}'
# Write-Output $msteams_payload
Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body $msteams_payload -Uri $webhookurl