Skip to content

PsychoData/Posh-AdaptiveCards

Repository files navigation

Posh-AdaptiveCards

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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published