Using aliases and the myth of the one-liner

The beginners section of the scripting games can be often answered with one pipeline of PowerShell.

Notice that I stated one pipeline not one line

Since the early days of PowerShell there has been an almost mystical reverence  paid to the concept of the “one-liner” ie boiling the PowerShell script down to a single line. That worked as a concept in PowerShell v1 where all we had was the console. When PowerShell v2 appeared with the ISEit was time to ditch the one line concept and switch our attention to what is important – using the PowerShell pipeline.

The pipeline symbol acts as a line continuation character so in ISE or any other PowerShell aware editor/environment you can split your pipeline over multiple lines of text BUT STILL HAVE A SINGLE PIPELINE.

Its more readable and easier to work with especially when debugging.

With PowerShell v3 and the changes to ISE it is finally time to kill the myth of the one liner and actually be honest about what we are trying to achieve – the one pipeline.

In a similar vein there is a lot of talk about how we should use aliases at the command prompt.


With tab completion it is almost as quick to use the full name for cmdlets and parameters especially if you have to look up the alias. If you like them fine but I prefer not to use them so that what ever I experiment with at the prompt can be copied straight into scripts.

This entry was posted in Powershell Basics. Bookmark the permalink.

2 Responses to Using aliases and the myth of the one-liner

  1. Dawn Villejoin says:

    I find that breaking the lines in logical places (of course after line continuation characters) makes it look much more presentable and has better readability. I wholeheartedly agree with the alias issue. It would take me longer to look up what the alias is for some cmdlets than to just hit the Tab key. Thanks for posting and thanks for judging!!

    • Hi Dawn

      Aliases are the one part of PowerShell I would like to remove as they are a distraction unless you know them well. It feels we are tryign to progress backwards to the old commad utilities where each had its own arcane syntax

      Good luck with the games

Leave a Reply

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

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

Twitter picture

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

Facebook photo

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

Google+ photo

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

Connecting to %s