Posted by: Richard Siddaway
when relevant content is
added and updated.
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.