Adding a Title to a PowerShell Window: A Guide

Take a look at the TechNet article about customizing the Windows PowerShell Console. One way to set the title when spawning a process is by using Solution 2. For a simpler approach, you can utilize the command provided in Solution 3 within the PowerShell window. This command can also be used in the Command prompt or RunAs Dialog Box to get the desired title in a traditional CMD styled window. Additionally, thanks to jimhark, a workaround has been found to make Solution 2 work without spawning a separate PowerShell process to send the Ctrl-C. By sending the GenerateConsoleCtrlEvent to the desired process group and attaching console back to it, the issue can be resolved.


Solution 1:

PS C:> $Host.UI.RawUI.WindowTitle = "New Window Title"

Adding this to your profile will ensure it appears on every new PS window.

Have a look at the TechNet piece titled “Personalizing the Windows PowerShell Command Line.


Solution 2:


If you wish to define the title during the spawning of a process.

$StartInfo = new-object System.Diagnostics.ProcessStartInfo
$StartInfo.FileName = "$pshomepowershell.exe"
$StartInfo.Arguments = "-NoExit -Command `$Host.UI.RawUI.WindowTitle=`'Your Title Here`'"
[System.Diagnostics.Process]::Start($StartInfo)


Solution 3:


The PowerShell window can be utilized to accomplish this task by implementing the subsequent command.

$host.ui.RawUI.WindowTitle = 'Some Name'

To open the PowerShell Window in the traditional CMD styled window with the desired Title, you can utilize the given command in either the Command prompt or the RunAs Dialog Box.

cmd /k PowerShell -NoExit -Command "& {$host.ui.RawUI.WindowTitle = 'Powershell'}"

This is comparable to the classic CMD but with the added benefits of PowerShell functionality and Syntax Highlighting.

Frequently Asked Questions