Forum Discussion

Thomas_Steibl's avatar
Thomas_Steibl
Brass Contributor
Feb 06, 2020
Solved

Send adaptive card via Powershell to a Teams Channel

I created an adaptive card and want to send it via PowerShell to a Teams Channel via a webhook. Everything works so far, but the card is shown as a blank line?!   
  • tomorgan's avatar
    tomorgan
    Feb 10, 2020

    Thomas_Steibl  Ah, ok, so I forgot something really important!  You can't use Adaptive Cards, you have to use the older MessageCard format. See https://docs.microsoft.com/en-us/outlook/actionable-messages/send-via-connectors for the detail, but this should work:


    $body = ' {
      "@context": "https://schema.org/extensions",
      "@type": "MessageCard",
      "themeColor": "0072C6",
      "title": "Using Microsoft Teams",
      "text": "Please make sure to read the User Guide first.",
      "potentialAction": [
        
        {
          "@type": "OpenUri",
          "name": "Request Office 365 Group",
          "targets": [
            { "os": "default", "uri": "https://teams.microsoft.com/l/entity/81fef3a6-72aa-4648-a763-de824aeafb7d/_djb2_msteams_prefix_316372079?context=%7B%22subEntityId%22%3Anull%2C%22channelId%22%3A%2219%3A96f7bce5c6e2472a8f6e896ef0e4f875%40thread.skype%22%7D&groupId=d622b046-74e2-46a4-a1c6-63411f915464&tenantId=5176709f-3f1f-4e44-a034-277655f7629c" }
          ]
        }
      ]
    }'
    

    Should give you:

     

Resources