-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsend-msteams-alert.ps1
53 lines (49 loc) · 1.41 KB
/
send-msteams-alert.ps1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# Powershell MS Teams alert template
#
# This is a template to demonstrate the ability to send notices to
# Microsoft Teams from PowerShell
#
# Parse the command variables
param (
[string]$message = "This is a test of the alert system",
[string]$title = "Test Message",
[string]$status = "Cleared",
[string]$monitor = "Testing - monitor",
[string]$location = "Downtown",
[string]$system = "labsys01"
)
# Edit the URI with the webhook url that was provided
$uri = 'https://outlook.office365.com/webhook/MISSING';
# Build the message Body
$body = ConvertTo-Json -Depth 4 @{
title = $title
text = ' '
sections = @(
@{
activityText = $message
},
@{
facts = @(
@{
name = 'Status'
value = $status
},
@{
name = 'System Name'
value = $system
},
@{
name = 'Monitor'
value = $monitor
},
@{
name = 'Location'
value = $location
}
)
}
)
}
#Send the message to MS Teams
Invoke-RestMethod -uri $uri -Method Post -body $body -ContentType 'application/json';
Write-Output "INFO - Message has been sent.";