I use PowerShell for a lot of administrative functions. So for different environments I have different administrative accounts that I run the PowerShell window as. When I have a few of these windows open at the same time it is hard to remember which window is for which environment. A simple solution to this is to add the domain and user id to the window title bar so it is easy to determine which environment or user account I’m working with.

You can do this manually by setting the property $host.UI.RawUI.WindowTitle . I don’t like this though because it becomes tedious to do every time you open a window. To fix that problem you just need to add a little script to a PowerShell profile and your done.

I added the following script to %windir%\system32\WindowsPowerShell\v1.0\Microsoft.PowerShell_profile.ps1 and now it is easy for me to remember which account I’m running under.

$h = get-host

$title = $h.UI.RawUI.WindowTitle

$h.UI.RawUI.WindowTitle = "$title ($($env:userdomain)\$($env:username))"

Sorry, comments are closed for this article.