Instantly share code, notes, and snippets.

Embed
What would you like to do?
PowerShell function that sends a message to Slack
function NotifySlack($webhookurl, $channel, $message)
{
$payload = @{
"channel" = $channel
"icon_emoji" = ":robot_face:"
"text" = $message
"username" = "Mr. Robot"
}
Invoke-WebRequest -UseBasicParsing -Body (ConvertTo-Json -Compress -InputObject $payload) -Method Post -Uri $webhookurl | Out-Null
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment