March 10, 2015

Powershell is en[TITLE]d!

Grumpy Admin here, does it not make you grumpy when you are running a script and the title of the Window is just Administrator: Windows Powershell. If you are old enough like me to remember DOS batch files, then you might remember a neat little command called TITLE – this allowed you to change the Title of the Window the batch file was running in  to a string that made more sense. For example, installing Please Wait. It was just a small little thing that gave your scripts a little flaw and polish!

Microsoft didn’t forget Powershell in this department and gave it the same ability and a whole lot  more and made it very very very easy to access all these methods. They have thrown all it all under the $host variable – well $Host.UI.RawUI to be exact.

So lets do a quick Get-Member on that and see what we get :-


As you can see, there is a property called WindowTitle which as the name says controls the Window Title,  we can access it like this :-

$host.UI.RawUI.WindowTitle =”Grumpy Admin”

and boom! The title of the Window has changed, a very quick and easy way to provide more feedback.


Here is a good example of how you could use this tip :-

for ($x=1; $x -lt 100; $x++) {
Write-Progress -Activity “Installing Grumpy Stuff” -CurrentOperation “$x% Grumpy” -Status “Please wait.”
$host.UI.RawUI.WindowTitle = “$x % Grumpy”
Start-Sleep 1