Skip to content

Instantly share code, notes, and snippets.

@DBremen
Forked from Tiberriver256/Show-HTML
Last active May 27, 2017 19:40
Show Gist options
  • Save DBremen/c4a61d8d890dc0ce5510de50fcc8e499 to your computer and use it in GitHub Desktop.
Save DBremen/c4a61d8d890dc0ce5510de50fcc8e499 to your computer and use it in GitHub Desktop.
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()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment