Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
MSTeams/send-msteams-alert.ps1
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
53 lines (49 sloc)
1.41 KB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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."; |