{"id":2342,"date":"2019-02-27T20:59:46","date_gmt":"2019-02-27T20:59:46","guid":{"rendered":"http:\/\/www.incredigeek.com\/home\/?p=2342"},"modified":"2019-02-27T21:00:10","modified_gmt":"2019-02-27T21:00:10","slug":"bash-script-to-send-messages-to-microsoft-teams","status":"publish","type":"post","link":"https:\/\/www.incredigeek.com\/home\/bash-script-to-send-messages-to-microsoft-teams\/","title":{"rendered":"Bash script to send messages to Microsoft Teams"},"content":{"rendered":"\n<p>Copy and save into teams.sh file.  Make executable.  Change web hook, Run!<\/p>\n\n\n\n<p>The script is a modified Slack script from off the web.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">#!\/bin\/bash<br># bash script to send messages to Microsoft Teams.<br> function usage {<br>     echo \"HELP ME!\"<br>     echo \"description: send messages to Microsoft Teams channels\"<br>     echo \"special notes: You'll need to change the teamsUrl variable to contain your webhook from Teams.\"<br>     echo \"usage: ${0} -b \\\"Message contents\\\"\"<br>     echo \"      -m    Message body\"<br>     echo \"      -h    This help info\"<br>     exit 1<br> }<br> while getopts \"m:h\" opt; do<br>   case ${opt} in<br>     m) msgBody=\"$OPTARG\"<br>     ;;<br>     h) usage<br>     ;;<br>     \\?) echo \"Invalid option -$OPTARG\" >&amp;2<br>     ;;<br>   esac<br> done<br># Add\/Change the webhook to one you created in Teams<br> teamsUrl=\"https:\/\/teamswebhook\"<br> if [[ ! \"${msgBody}\" ]]; then<br>     echo \"You didn't specify a message!\"<br>     usage<br> fi<br> read -d '' payLoad &lt;&lt; EOF<br> {<br>                     \"text\": \"${msgBody}\",<br> <code>}<\/code><br>EOF<br>statusCode=$(curl \\<br>--write-out %{http_code} \\<br>--silent \\<br>--output \/dev\/null \\<br>-X POST \\<br>-H 'Content-type: application\/json' \\<br>--data \"${payLoad}\" ${teamsUrl})<br>echo ${statusCode}<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Copy and save into teams.sh file. Make executable. Change web hook, Run! The script is a modified Slack script from off the web. #!\/bin\/bash# bash script to send messages to Microsoft Teams. function usage { echo &#8220;HELP ME!&#8221; echo &#8220;description: &hellip; <a href=\"https:\/\/www.incredigeek.com\/home\/bash-script-to-send-messages-to-microsoft-teams\/\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[266],"tags":[211,7,13,173,589],"class_list":["post-2342","post","type-post","status-publish","format-standard","hentry","category-scripts","tag-bash","tag-linux-2","tag-microsoft","tag-script","tag-teams"],"_links":{"self":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2342","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/comments?post=2342"}],"version-history":[{"count":2,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2342\/revisions"}],"predecessor-version":[{"id":2344,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/posts\/2342\/revisions\/2344"}],"wp:attachment":[{"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/media?parent=2342"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/categories?post=2342"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.incredigeek.com\/home\/wp-json\/wp\/v2\/tags?post=2342"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}