Skip to content

Instantly share code, notes, and snippets.

@General-Gouda
Last active September 20, 2017 12:58
Show Gist options
  • Save General-Gouda/a8af69308e2d0f894bd12e8535399479 to your computer and use it in GitHub Desktop.
Save General-Gouda/a8af69308e2d0f894bd12e8535399479 to your computer and use it in GitHub Desktop.
Commands to hide or show a PowerShell console window.
function Show-PowerShell() {
$null = $showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 10)
}
function Hide-PowerShell() {
$null = $showWindowAsync::ShowWindowAsync((Get-Process –id $pid).MainWindowHandle, 2)
}
$script:showWindowAsync = Add-Type –memberDefinition @”
[DllImport("user32.dll")]
public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);
“@ -name “Win32ShowWindowAsync” -namespace Win32Functions –passThru
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment