Living a SharePoint life

Wednesday, October 9, 2013

The Retro Powershell - Looking good in 8-Bit | Part 1

I wrote a little script that, when placed in your PowerShell Profile, will print a message similar to the old boot message you got from your breadbox.


Like a lot of people out there I started my IT career with a Commodore 64. It is still today a class of its own and amazing to see what people are capable to do with this incredible machine. Not only was the Commodore64 the best selling home computer of all times, it still has a huge fan base today. So why not get back the good old feeling back into your PowerShell?



Changing the Shell Colors


The Shell colors are stored in the Windows registry. Unfortunately we cannot change them from the Shell and there is only a hack to manipulate the registry. I don’t like the idea to tamper with the registry every time the profile is loaded, especially when we only have to set the colors once. So the best to do is change the colors of your PowerShell by hand.
We need the nice dark blue for the background and the light blue of the foreground. The color codes are as follow:

  • Dark blue – R: 62, G: 49, B: 162
  • Light blue – R: 124, G: 112, B: 218

If you don’t like the contrast, just adjust them as needed.

Adding code to your profile


Open your profile file to edit some code. If you don’t know what your profile is, I suggest you read this Technet article first.


Add the following code at the end of your profile file and save your work.

#
# Make this the last entry, because it clears the shell screen
# Writing the C64 boot screen to the shell
#
Set-Location C:\
$Win32OS = Get-WmiObject -Class Win32_OperatingSystem
$FreeMB = [math]::round(($Win32OS.FreePhysicalMemory /1024), 0)
$TotalGB = [math]::round(($Win32OS.TotalVisibleMemorySize /1024 /1024),1)
$osName = $Win32OS.Caption
$ver = $Host.Version.Major
$width = $Host.UI.RawUI.WindowSize.Width

$Host.UI.RawUI.WindowTitle = "Power 64 Shell"

$message1 = "**** $osName POWERSHELL V$ver ****"
$message2 = "$TotalGB GB RAM SYSTEM  $FreeMB POWERSHELL MEGABYTES FREE"
Clear-Host
$screenXpos = [Math]::Truncate(($width - $message1.Length) / 2)
[Console]::SetCursorPosition($screenXpos, 1)
Write-Host $message1
$screenXpos = [Math]::Truncate(($width - $message2.Length) / 2)
[Console]::SetCursorPosition($screenXpos, 3)
Write-Host $message2
Write-Host
Write-Host "READY."; Write-Host

That’s it, enjoy your C64 retro feeling with the PowerShell.

Other ideas


Of course the Commodore64 wasn’t the only 8-Bit machine around. You could as well change the script to look more like an Atari 800XL or CPC.

Update

I've added a part 2 post that discribes how to change the font of the PowerShell as well.
Part 3 is an update for PowerShell Core and Windows Terminal.
Got any Ideas of your own? Post them in the comments below.

This post is

Featured Post

How are Microsoft Search quota consumed?

With Office 365 Search, Microsoft has created a central entry point for the modern workplace. In one convenient spot, users can access all ...