* PowerShellでIncoming Webhook [#wf2ecd5e]
** 事前準備 [#g26f7abd]
- Slackにログインする
- https://my.slack.com/services/new/incoming-webhook/ を開く
- Postする対象のチャンネルを選択して、[Add]をクリックする
- [Setup Instructions]から[Webhook URL]を確認して、控える
-- 今回は、https://hooks.slack.com/services/ABC/XYZ/012345
** PowerShellでIncoming WebHooksを実行 [#q2321ba9]
$url = "https://hooks.slack.com/services/ABC/XYZ/012345"
$data = @{ "text" = "Hello, World!"; "username" = "ghost-bot"; "icon_emoji" = ":ghost:"; "channel" = "#general" }
$json_str = $data | ConvertTo-Json
$body = [System.Text.Encoding]::UTF8.GetBytes($json_str)
Invoke-WebRequest -Method Post -Uri $url -ContentType "application/json" -Body $body