Powershell Best Practice #23: Avoid the horizontal scrolling (too long one-liners commands)

By | October 10, 2015

Best Practice: You should avoid the need to use the horizontal scrolling in scripts to keep longs commands more readable.

Explanation: If you write the previous command inside a script, it will be definitely not useful to read.

There are several issues :

  • If I want to see this command, I need to use the horizontal scrolling
  • It is harder to read, update and debug
  • If I have an add-on (ex: CIM Explorer), I could need to close that to temporarily increase the witdh view

Example 1 (with no pipeline)


A better approach is to use splatting:


Example 2 (with pipeline)


And now see the difference here, it is much easier to read.


Note: With ISESteroids, you have the feature “Toggles word wrap”:




Leave a Reply

Your email address will not be published. Required fields are marked *