Skip to content

Instantly share code, notes, and snippets.

@Tiberriver256
Last active January 5, 2024 08:24
Show Gist options
  • Save Tiberriver256/589be08ff7db0560db8a3b9cbc02fc07 to your computer and use it in GitHub Desktop.
Save Tiberriver256/589be08ff7db0560db8a3b9cbc02fc07 to your computer and use it in GitHub Desktop.
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment