Just a quick post on something I saw lot of people wonder about: How do you hide and show console window when using forms with PowerShell?

The p/Invoke calls required can be found in numerous web resources and also in Poweshell in Action book.
Here is prototype of the soulution:

Add-Type -Name Window -Namespace Console -MemberDefinition '
public static extern IntPtr GetConsoleWindow();

public static extern bool ShowWindow(IntPtr hWnd, Int32 nCmdShow);

function Show-Console {
   $consolePtr = [Console.Window]::GetConsoleWindow()
  #5 show
 [Console.Window]::ShowWindow($consolePtr, 5)

function Hide-Console {
    $consolePtr = [Console.Window]::GetConsoleWindow()
  #0 hide
 [Console.Window]::ShowWindow($consolePtr, 0)

[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$Form = New-Object System.Windows.Forms.Form

$showButton = New-Object System.Windows.Forms.Button
$showButton.Text = 'ShowConsole'
$showButton.Top = 10
$showButton.Left = 10
$showButton.Width = 100

$hideButton = New-Object System.Windows.Forms.Button
$hideButton.Text = 'HideConsole'
$hideButton.Top = 60
$hideButton.Left = 10
$hideButton.Width = 100


Description of the functions and more possible values for the ShowWindow can be, as usual, found in Microsoft documentation:
GetConsoleWindow function
ShowWindow function