DBremen
5/27/2017 - 7:39 PM

Show-HTML

function Show-HTML ([string]$HTML){
    Add-Type ‚ÄďAssemblyName PresentationFramework
    if(Test-Path $HTML -IsValid){
        $txt = Get-Content $HTML -Raw
        $HTML = $txt
    }
    $HTML.Replace('<head>','<meta name="viewport" content="width=device-width, initial-scale=1"><meta http-equiv="X-UA-Compatible" content="IE=edge" /><meta http-equiv="Content-Type" content="text/html;charset=utf-8">')
    [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 )
    $WebBrowser = $Form.FindName("WebBrowser")
    $WebBrowser.NavigateToString($HTML)
    $Form.ShowDialog()
}