PowerShell Module to make it much simpler to install and use the .NET AdaptiveCard Templating SDK. For more information on Adaptive Cards in general, take a look at the Adaptive Cards landing page.
Install-Module -Name Posh-AdaptiveCards
For prototyping or designing your cards, I would highly recommend the Adaptive Cards Designer or maybe take a look at some Samples.
Templates let you apply significant formatting to simpler data, to make it into a much more displayable, adaptable, and reusable state. For more information check out the Templating Overview.
Here are a few references that may be useful
If you think your template might be useful to others, consider submitting it to the central template repo for the Adaptive Card Template Service. This will allow the AdaptiveCard Templates to be discovered and used through the Template Service API, as well as making the templates publicly accessible if you want to populate it offline.
Note: These Here-strings must be single-quote, and not double-quote.
Install-Module -Name Posh-AdaptiveCards
$TemplateJSON= @'
{
"type": "AdaptiveCard",
"version": "1.3",
"body": [
{
"type": "TextBlock",
"text": "Hello ${Name}!"
}
]
}
'@
$DataJSON = @'
{
"Name": "Matt Thompson"
}
'@
New-AdaptiveCardInstance -Data $DataJSON -Template $TemplateJSON
which yields the ready-to-post JSON
{"type":"AdaptiveCard","version":"1.3","body":[{"type":"TextBlock","text":"Hello Matt Thompson!"}]}
AdaptiveCard Templating uses a format of ${Object.Property}
for it's variables. PowerShell uses a similar and compatible format for its normal variables. Strings you use to create your strings should be Single-quotes to prevent PowerShell mistakenly trying to expand the variable too early.
$quoteSampleTemplate = @'
{ "Property": "${Value}" }
'@
and not double-quotes
#THIS will not work as expected due to double-quotes Variable Expansion
$doubleQuoteSampleTemplate = @"
{ "Property": "${Value}" }
"@