EvotecIT/PSTeams

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

dcvlehr opened this issue · 8 comments

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?

What code are you using?

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

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.

$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.

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

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

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)?

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