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

This message is too long to display here. Please visit the link to read the content. #14

Closed dcvlehr closed 3 years ago

dcvlehr commented 4 years ago

Grabbing a list of servers and trying to alert via MS teams when criteria is met. When I pass the list, I get the message "This message is too long to display here. Please visit the link to read the content." in the MS teams card.

How do you make it where you can click to view more? Or embed a table with scroll bars?

PrzemyslawKlys commented 4 years ago

What code are you using?

dcvlehr commented 4 years ago

I am trying to pass the text output of the $testing variable to be sent to a teams message. I just did an update-module psteams and then did the following:

$testing = $Compare | Out-String

Function Invoke-NotifyTeams {
    $TeamsID = 'XXXX'
    Send-TeamsMessage -URI $TeamsID -MessageTitle 'List of servers' -MessageText "blah blah" -Color red {
        New-TeamsSection {
            New-TeamsActivityTitle -Title 'title'
            New-TeamsActivitySubtitle -Subtitle 'subtitle'
            New-TeamsActivityText -Text $testing
            New-TeamsFact -Name 'PS Version' -Value 'some value'
            New-TeamsButton -Name 'servers' -Link "https://link.com"
        }
    }
}
invoke-notifyteams
PrzemyslawKlys commented 4 years ago

Can't you simply use multiple teamsfact? one per each server?

Function Invoke-NotifyTeams {
    $TeamsID = 'XXXX'
    Send-TeamsMessage -URI $TeamsID -MessageTitle 'List of servers' -MessageText "blah blah" -Color red {
        New-TeamsSection {
            New-TeamsActivityTitle -Title 'title'
            New-TeamsActivitySubtitle -Subtitle 'subtitle'
            New-TeamsActivityText -Text $testing
            foreach ($_ in $Compare) {
                     New-TeamsFact -Name $_.ServerName -Value "SomeValue from Compare"
            } 
            New-TeamsButton -Name 'servers' -Link "https://link.com"
        }
    }
}

I don't know what you have in $Compare but I do hope it's an object that has a list of servers. Hopefully, each server has some additional property that says something about the failed server? New-TeamsFact per server will give you nicer output.

dcvlehr commented 4 years ago

$compare is the output of compare-object which returns only the servers that do not yet have an NSX tag on them. This is supposed to post to teams weekly to catch servers that were missed.

I haven’t tried a new-teamsfact per server. That seems like a lot of new-teamsfacts.

PrzemyslawKlys commented 4 years ago

Well you can always try and split it. The string is probably too long.

dcvlehr commented 4 years ago

Tried what you posted here. When adding the foreach loop, teams message will not post at all. No errors indicated. Just doesnt go through

PrzemyslawKlys commented 4 years ago

Try using it with a Verbose switch. It's hard to help without all the information on how you're doing it. Maybe the message is just too big to handle. Can you post verbose here (removing any confidential information of course)?

PrzemyslawKlys commented 3 years ago

You can try using Adaptive Cards and see if that resolves your issues. Closing as stale.