Local Adaptive Cards Templating in PowerShell

Posh-AdaptiveCards

I made a 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.

Installation

Install-Module -Name Posh-AdaptiveCards    

Prototyping / Designing Cards

For prototyping or designing your cards, I would highly recommend the Adaptive Cards Designer or maybe take a look at some Samples.

What are Templates

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.

More info & References

Here are a few references that may be useful

Contributing to the Community

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.

Example

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!"}]}

Double-Quotes and Powershell

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}" } 
"@

image


1 comment:

  1. Their most spectacular recreation is their 3D on-line slots which have quite a number of} followers. However, you might be} violating Washington State regulation should you knowingly gamble via an online playing website . Washington regulation prohibits any on-line playing by and it is a class C felony to knowingly transmit or obtain playing data by telephone, internet, or another comparable means. The 카지노사이트 major legislation regulating the online playing industry is the Online Gambling Regulation Act 2001, generally abbreviated to OGRA.

    ReplyDelete

Putting your public website on your Domain Controllers .... Sort of

In a post a while back I talked about a current trend to move websites from www.contoso.one to just contoso.one . The method I outlined in t...