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

PSCustomObject conversion bug #55

Closed chaoscreater closed 1 year ago

chaoscreater commented 1 year ago

There seems to be a bug with the conversion of my PSCustomObject to a New-AdaptiveTable.

Say if I have this:

$Expired_Table

ResourceName     : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CertificateName  :
IssueDate        : 29-May-2020 5:34:49 am
ExpiryDate       : 9-Aug-2022 10:02:10 pm +00:00
SubscriptionName : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ResourceGroup    : xxxxxxxxxxxxxxxxxxxxxxxx

ResourceName     : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CertificateName  : abc123
IssueDate        : 22-Jan-2020 8:57:38 pm
ExpiryDate       : 9-Aug-2020 10:02:10 pm +00:00
SubscriptionName : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ResourceGroup    : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

ResourceName     : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
CertificateName  :
IssueDate        : 29-May-2020 5:34:49 am
ExpiryDate       : 9-Aug-2022 10:02:10 pm +00:00
SubscriptionName : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
ResourceGroup    : xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Notice how some of the elements do not have a value in some of the properties. It could be null for either ResourceName or CertificateName. In that case, I'd expect the table output in Teams to show nothing for that column. But instead, the values get shifted. So for example, the CertificateName from the second element (abc123) gets shifted to the CertificateName under the first element.

However, $Expired_Table itself has the correct output. It's only when it gets converted to an adaptive table that it becomes messed up.


# Teams webhook send message
$Card = New-AdaptiveCard {

    New-AdaptiveTable -DataTable $Table_Expired -HeaderHorizontalAlignment Left -HorizontalAlignment Left -HeaderColor Good -Size Small

} -Uri $teamsWebhook -FullWidth -ReturnJson
PrzemyslawKlys commented 1 year ago

This is related to Adaptive Tables:

I need to find a workaround of sort. Inserting empty space doesn't work reliably.