How to Set Custom Window Titles in PowerShell (Equivalent to CMD’s TITLE Command)


9 views

When working with multiple PowerShell consoles, it's incredibly useful to set custom window titles - just like we used to do with CMD's TITLE command. Here's how to achieve this in PowerShell with various approaches.

The simplest way to set your PowerShell window title is using the host's RawUI property:

$Host.UI.RawUI.WindowTitle = "Finance Department Console"

This changes the title immediately and works in both Windows PowerShell and PowerShell Core.

For persistent titles across sessions, add this to your PowerShell profile:

function Set-Title {
    param([string]$newTitle)
    $Host.UI.RawUI.WindowTitle = $newTitle
}

Set-Title "Email Administration Console"

You can make your titles dynamic by including useful information:

$Host.UI.RawUI.WindowTitle = "SQL Admin - $(Get-Date -Format 'HH:mm') - $($env:COMPUTERNAME)"

Here's a more advanced example that updates the title automatically when you change directories:

function prompt {
    $Host.UI.RawUI.WindowTitle = "PS: $(Get-Location) - $env:USERNAME"
    "PS $($executionContext.SessionState.Path.CurrentLocation)$('>' * ($nestedPromptLevel + 1)) "
}

For completeness, here are two other methods:

[System.Console]::Title = "Backup Process Console"

# Or using Windows API (more complex but powerful)
$code = @"
[DllImport("kernel32.dll")]
public static extern bool SetConsoleTitle(string lpConsoleTitle);
"@
Add-Type -MemberDefinition $code -Name NativeMethods -Namespace Kernel32
[Kernel32.NativeMethods]::SetConsoleTitle("Custom API Title")

If your titles aren't sticking, check:

  • The console host may not support title changes (rare)
  • Other scripts might be overriding your title
  • In ISE, window title behavior differs from the console

Windows administrators coming from CMD background often miss the simple title command that instantly changes the console window caption. In batch scripting, we'd simply use:

title Finance Department
title Email Administration

PowerShell provides the same functionality through the $host automatic variable. Here's how to modify your window title:

$host.UI.RawUI.WindowTitle = "Financial Reporting Module"

This changes the title immediately, just like the CMD version did. The RawUI property gives you access to the host's user interface elements.

For better organization of multiple PowerShell sessions, you can combine this with other information:

$host.UI.RawUI.WindowTitle = "PS-$(Get-Date -Format 'HH:mm') | DB Maintenance"

This creates a title like: PS-14:30 | DB Maintenance

Let's build a proper replacement for the CMD title command that you can add to your profile:

function Set-PSWindowTitle {
    param(
        [Parameter(Mandatory=$true)]
        [string]$Title
    )
    $host.UI.RawUI.WindowTitle = $Title
}

Set-Alias title Set-PSWindowTitle

Now you can use it exactly like in CMD:

title Inventory Management

For power users managing multiple environments, you can create dynamic titles:

$currentLocation = (Get-Location).Path
$host.UI.RawUI.WindowTitle = "PS: $($currentLocation.Split('\')[-1]) | $(whoami)"

This shows the current folder and username in the title bar.

Remember that each PowerShell host (ISE, Console, VS Code) might handle titles slightly differently. The above examples work in the standard PowerShell console host.

For PowerShell ISE, you'll need to use:

$psISE.CurrentPowerShellTab.DisplayName = "My Custom Title"