Skip to content

Instantly share code, notes, and snippets.

@webmastir
Forked from aaldrich29/Send-SlackMessage.ps1
Created February 25, 2018 03:05
Show Gist options
  • Select an option

  • Save webmastir/0d9bc4b3d4e9d0f2962aa3b614e17c63 to your computer and use it in GitHub Desktop.

Select an option

Save webmastir/0d9bc4b3d4e9d0f2962aa3b614e17c63 to your computer and use it in GitHub Desktop.

Revisions

  1. @aaldrich29 aaldrich29 created this gist Apr 22, 2016.
    15 changes: 15 additions & 0 deletions Send-SlackMessage.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,15 @@
    function Send-SlackMessage {
    # Add the "Incoming WebHooks" integration to get started: https://slack.com/apps/A0F7XDUAZ-incoming-webhooks
    param (
    [Parameter(Mandatory=$true, Position=0)]$Text,
    $Url="https://hooks.slack.com/services/xxxxx", #Put your URL here so you don't have to specify it every time.
    # Parameters below are optional and will fall back to the default setting for the webhook.
    $Username, # Username to send from.
    $Channel, # Channel to post message. Can be in the format "@username" or "#channel"
    $Emoji, # Example: ":bangbang:".
    $IconUrl # Url for an icon to use.
    )

    $body = @{ text=$Text; channel=$Channel; username=$Username; icon_emoji=$Emoji; icon_url=$IconUrl } | ConvertTo-Json
    Invoke-WebRequest -Method Post -Uri $Url -Body $body
    }