Add-Type @" using System; using System.Runtime.InteropServices; public static class ConsoleForegroundHelper { [DllImport("user32.dll")] public static extern bool SetForegroundWindow(IntPtr windowHandle); [DllImport("kernel32.dll")] public static extern IntPtr GetConsoleWindow(); } "@ [void][ConsoleForegroundHelper]::SetForegroundWindow([ConsoleForegroundHelper]::GetConsoleWindow())