PowerShell

PowerShell: Customizing the Title Bar of your PowerShell Console Window

If you use PowerShell often, a title bar of your own will make a powerful impression. You certainly have noticed that my screenshots always show the entire console window and you also may have noticed that I have customized my title bar.

If you have no clue what I’m talking about take a look at my console title bar shown below.

Unbenannt.png

Cool stuff ha? Now we will define a title for your console window together. Let’s start.

Prerequisites

1. PowerShell Profile ($profile)

First of all, it’s worth to mention that the content of the standard console window title bar is modified every time you start PowerShell. It’s not permanent and it has to be configured per user. For customizing the title bar we need a PowerShell profile file. If you already have one, the following command returns true.


Test-Path $profile

Unbenannt.PNG

Bild1.png

If it returns false, create a profile file with the one-liner below. The command will create a new profile file in the users directory.


New-Item $PROFILE -ItemType File -Force

Bild2.png

2. Execution Policy

There’s one more thing we gotta do before we can start. We have to check the execution policy status. The PowerShell execution policy is designed to prevent unintentional and accidental code execution of ps1 files. To allow the execution of our previously configured profile file we have to take a look at the status of the execution policy of the local computer.


Get-ExecutionPolicy

Bild3.png

If the command returns Restricted, we have to change the status to RemoteSigned or Unrestricted (not recommended).


Set-ExecutionPolicy -ExecutionPolicy RemoteSigned

Bild4.png

Now we are ready for the main part. Please double check the prerequisites.

  • Did you configure the profile file? ==> Test-Path $profile
  • Did you check the Execution Policy? ==> Get-ExecutionPolicy

Customizing the PowerShell Title Bar

Now we have reached the main part of this blog post. In a few minutes your PowerShell window title bar will be equipped with your own style.

In PowerShell run the command ise $profile. This should open your profile file in PowerShell ISE.


ise $profile

Unbenannt.PNG

Copy the code below to line 1.


$host.ui.rawui.windowtitle="YOUR TITLE"

Now, customize the content of “YOUR TITLE” to suit your needs.

For example, the file might look like this:

Unbenannt.PNG

@Off Topic: In addition, I always set the execution location to C:. That is more pleasant than C:\Users … And further, I clear the screen with Clear Host.

Unbenannt.PNG

Now save the file and close PowerShell ISE.

We’re done. Now close and reopen PowerShell.

Voila!

Bild5.png

If you want to use special characters, use the type [char].

Unbenannt.PNG

This leads to the following title bar.

Bild6.png

To explore all characters see https://www.rapidtables.com/code/text/unicode-characters.html

Have fun with your new PowerShell title bar.

Further details

More about PowerShell Profiles here: https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_profiles?view=powershell-6

Categories: PowerShell

Tagged as: ,

2 replies »

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.