Show-HTML

This is just going to be a quick tip but I have not posted in awhile and thought I would share this little quick hit. PowerShell has a SUPER useful command for rendering variables in PowerShell into HTML called ConvertTo-HTML and of course HTML in general is really easy to spice up a bit as far as the looks go.

How can we show that information to an end user in a pop-up?

Since PowerShell has full .NET access we can pass an HTML string into an embedded WPF WebBrowser?

Usage of the function is:

$HTML = Get-Process | select name,id | ConvertTo-HTML | Out-String
Show-HTML -HTML $HTML

And this is what we would see:

Cool! Now we can start to build some interesting result pages for our scripts or interesting popups to show. Check out a couple of my more simple samples using this same technique:

function Show-HTML ([string]$HTML)
{

    [void][System.Reflection.Assembly]::LoadWithPartialName('presentationframework')
    [xml]$XAML = @'
    <Window
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="PowerShell HTML GUI" WindowStartupLocation="CenterScreen">
            <WebBrowser Name="WebBrowser"></WebBrowser>
    </Window>
'@

    #Read XAML
    $reader=(New-Object System.Xml.XmlNodeReader $xaml)
    $Form=[Windows.Markup.XamlReader]::Load( $reader )
    #===========================================================================
    # Store Form Objects In PowerShell
    #===========================================================================
    $WebBrowser = $Form.FindName("WebBrowser")

    $WebBrowser.NavigateToString($HTML)

    $Form.ShowDialog()
}

Read More

ThingWorx local development environment with Docker - Part 1 Reading time ~3 minutes

[ThingWorx](https://www.ptc.com/en/products/thingworx) is a platform for developing "Industrial IoT solutions". They've......

Estimate, target, plan and commit Reading time ~1 minute

I've started into "[Software Estimation: Demystifying the Black Art](https://www.amazon.com/Software-Estimation-Demystifying-Developer-Practices/dp/0735605351)" by......

How to run multiple versions of React side-by-side using Single Spa Reading time ~2 minutes

This seems like it should be easy right? [Single-spa](https://single-spa.js.org/) is......