Skip to content

Instantly share code, notes, and snippets.

@ErikHen
Last active November 22, 2017 21:07
Show Gist options
  • Save ErikHen/c61c9ec228c8e099af0dbfb96bd75dbf to your computer and use it in GitHub Desktop.
Save ErikHen/c61c9ec228c8e099af0dbfb96bd75dbf to your computer and use it in GitHub Desktop.
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