EvotecIT / PSTeams

PSTeams is a PowerShell Module working on Windows / Linux and Mac. It allows sending notifications to Microsoft Teams via WebHook Notifications. It's pretty flexible and provides a bunch of options. Initially, it only supported one sort of Team Cards but since version 2.X.X it supports Adaptive Cards, Hero Cards, List Cards, and Thumbnail Cards. All those new cards have their own cmdlets and the old version of creating Teams Cards stays as-is for compatibility reasons.
MIT License
409 stars 41 forks source link

Failing to send a message doesnt generate an error #21

Closed SQLDBAWithABeard closed 4 years ago

SQLDBAWithABeard commented 4 years ago

So I was trying to send a message to test the module

I tried to send a very simple message, nothing arrived, no error.

I searched for Get-Help (see #20 ) and then explored the parameters

I saw -ShowErrors

I ran with that and still had no errors

I ran with verbose and saw the 404 error

image

PrzemyslawKlys commented 4 years ago

Can't reproduce your error:

image

Send-TeamsMessage -uri $TeamsID -MessageTitle "Foo" -MessageText "Foo ❌ 😀 💩 bar" -Verbose

ShowErrors is strictly for Pester usage, Verbose does give you all the details. I would say the TeamsID you provided doesn't exists?

What would you expect here? detect the error and display it as a warning?

PrzemyslawKlys commented 4 years ago

Weirdly enough if I remove one or two chars from the webhook URL it throws an error which displays warning

WARNING: Send-TeamsMessage - Couldn't send message. Error: The remote server returned an error: (400) Bad Request.

So in your case the 404 error must be non throwing for Invoke-RestMethod.

PrzemyslawKlys commented 4 years ago

Added an option to detect error or failed strings within response from Invoke-RestMethod. Hopefully, this will allow for a better understanding of something failed. Also added ErrorAction Stop. So far it wasn't needed as it was throwing errors, but maybe some edge case.

Please let me know if you find out what is the problem on your end? Published new version.