Maximize window and bring it in front with powershell
[void] [System.Reflection.Assembly]::LoadWithPartialName("'Microsoft.VisualBasic")
$shell = New-Object -ComObject “Shell.Application”
$shell.MinimizeAll()
$a = Get-Process | Where-Object {$_.Name -like "powershell"}
[Microsoft.VisualBasic.Interaction]::AppActivate($a.ID)
Set-ForegroundWindow (Get-Process PowerShell).MainWindowHandle
Set-ForegroundWindow (Get-Process -id $pid).MainWindowHandle
$sig = '[DllImport("user32.dll")] public static extern bool ShowWindowAsync(IntPtr hWnd, int nCmdShow);'
Add-Type -MemberDefinition $sig -name NativeMethods -namespace Win32
Stop-Process -Name Notepad -ea 0;Notepad.exe
$hwnd = @(Get-Process Notepad)[0].MainWindowHandle
# Minimize window
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 2)
# Restore window
[Win32.NativeMethods]::ShowWindowAsync($hwnd, 4)
Stop-Process -Name Notepad