The Search for a Better PowerShell Console Experience

Doctor Scripto

Summary: Microsoft Scripting Guy, Ed Wilson, talks about the search for a better Windows PowerShell console experience.

Microsoft Scripting Guy, Ed Wilson, is here. This morning I am sipping a cup of English Breakfast tea. I added bits of spearmint, peppermint, and licorice root, along with a cinnamon stick and some lemon peel, lime peel, and orange peel. It is quite refreshing and has a bit of a bite to it. I picked up some Biscotti yesterday when I made a food run, so I am trying to be careful to not get crumbs in my keyboard.

You know I love drinking tea. In particular, I love mixing and blending my own tea experience. If I was limited to a few dried out tea bags, however, I don’t think I would enjoy tea half as much. It is sort of like comparing fast-food drive-through coffee with a nice cup of coffee I make when I grind my own Kona beans and add fresh spring water to my French press. Just no comparison.

In a way, this all relates to using the Windows PowerShell console. How you might ask? Well, let me tell you…

The problem with the Windows PowerShell console

Actually, there is no problem, per se, with the Windows PowerShell console. If you grew up in the Windows world, and you spent most of your IT career pointing with mice and clicking icons, you more than likely have no problem with the Windows PowerShell console.

If your experience is limited to using Cmd.exe to run command-line utilities such as netsh, WMIC, or even netdom.exe, coming to the Windows PowerShell console will, in fact, be a big relief.

Like the person who drives through a fast-food restaurant every morning on the way to work to get a cup of coffee, what one has is what one is used to dealing with. As long as the little plastic lid stays on the paper cup, all is well with the world. But once one goes to a place where they take pride in the flavor of their coffee, and one tastes the rich flavors, smells the exotic fragrances, and savors the perfect cup of coffee, one immediately begins to seek to replicate that experience, and no longer can fast-food, drive-through coffee satisfy.

People who have had a rich and powerful console experience and come to Windows PowerShell are left impressed with the power of the Windows PowerShell cmdlets, the immediate access to the .NET Framework, and the power of the pipeline. But they are sadly unfulfilled with the overall console experience and are left wanting.

That is, until now.

PSReadLine: solution to the problem

One of the cool things introduced in Windows PowerShell 3.0 was a hook so that line editing could be improved. Before this, the experience in the Windows PowerShell console was pretty much limited to the same functionality that existed in the decades old Cmd.exe in Windows.

The cool thing is that Jason Shirk from the Windows PowerShell team used this hook and created a GitHub project called PsReadLine. If you have PSGet, the installation is as simple as typing the following:

Install-Module PSReadline

Note  PSGet is a community project that provides an easy interface into GitHub. After it is installed, modules such as Install-Module, Get-PSGetModuleInfo, and Update-Module become available.

If you don’t have PSGet, you can copy the file from GitHub. After you unblock the zip file, unzip the files and save them to your modules directory. One of the nice things about PSGet is that I can easily update a module (should a new version come available) by typing Update-Module PSReadLine, for example.

If I use Install-Module to install the module, it updates my Windows PowerShell profile to import the PSReadLine module. If I did a manual installation, I need to add the Import-Module PSReadLine command. Because PSReadLine only works in the Windows PowerShell console, depending on which Windows PowerShell profile I edit, I may need to add a bit of logic to avoid loading it in the Windows PowerShell ISE. This is the command I use in my Windows PowerShell profile:

If($host.Name -eq 'ConsoleHost') {import-module PSReadline}

PSReadLine provides what?

After I have installed PSReadLine, what do I get? For one thing, I get color coding in the Windows PowerShell console. No longer am I limited to basic blue and white. This is shown here:

Image of command output

Another helpful feature provided by PSReadLine is real-time syntax checking. If I have an error, such as a missing quotation mark or a missing curly brace, the prompt changes from the default white to red. This visual indicator tells me that I need to pay attention to my line and look for errors prior to running the command. This indicator is shown in the following image:

Image of indicator

The really cool thing is that PSReadLine is customizable, which means I can write my own key bindings and customize many of the default settings. One of the things I like is that I can display potential parameters. I press CTRL + Spacebar. It displays all options under my line, and it brings me back to where I need to be so that I can type my command. This is shown here:

Image of command output

These reasons alone are enough for me to download and install the free PSReadLine module, but there are many more features. Here is the list from the GitHub site:

  • Syntax coloring
  • Simple syntax error notification
  • A better multiline experience (for editing and history)
  • Customizable key bindings
  • Cmd and Emacs modes (neither are fully implemented yet, but both are usable)
  • Many configuration options
  • Bash style completion (optional in Cmd mode, default in Emacs mode)
  • Bash/zsh style interactive history search (CTRL-R)
  • Emacs yank/kill ring
  • Windows PowerShell token-based "word" movement and kill
  • Undo/redo

That is all there is to downloading and to using PSReadLine. Join me tomorrow when I will talk about more cool things that I can do with PSReadLine.

I invite you to follow me on Twitter and Facebook. If you have any questions, send email to me at, or post your questions on the Official Scripting Guys Forum. See you tomorrow. Until then, peace.

Ed Wilson, Microsoft Scripting Guy 


Discussion is closed.

Feedback usabilla icon