Add-Type -AssemblyName "PresentationCore", "PresentationFramework", "WindowsBase" [xml]$xamlMarkup = @' '@ $xamlGui = [System.Windows.Markup.XamlReader]::Load((New-Object System.Xml.XmlNodeReader $xamlMarkup)) $xamlMarkup.SelectNodes('//*[@Name]') | ForEach-Object { New-Variable -Name $_.Name -Value $xamlGui.FindName($_.Name) } #region Script Functions function Hide-Console { <# .SYNOPSIS Hide Powershell console before show WPF GUI. #> [CmdletBinding()] param () Add-Type -Name Window -Namespace Console -MemberDefinition ' [DllImport("Kernel32.dll")] public static extern IntPtr GetConsoleWindow(); [DllImport("user32.dll")] public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow); ' [Console.Window]::ShowWindow([Console.Window]::GetConsoleWindow(), 0) } function Join-ToGithub { <# .SYNOPSIS Open "https://github.com/farag2/Windows-10-Setup-Script" in default browser. #> [CmdletBinding()] param () Start-Process -FilePath "explorer.exe" -ArgumentList "https://github.com/farag2/Windows-10-Setup-Script" } #endregion #region Controls Events $Window.Add_MouseLeftButtonDown({ $Window.DragMove() }) $ButtonClose.Add_MouseLeftButtonDown({ $Window.Close() }) $TextBlock_GitHub.Add_MouseLeftButtonDown({ Join-ToGithub }) #endregion Hide-Console $Window.ShowDialog() | Out-Null