BPuhl’s Blog

A little bit of everything without actually being much of anything

It’s not a "one-liner" if…

Posted by BPuhl on February 15, 2008

…the language syntax allows you to nest and pipe a dozen commands together.

This seems to be a common theme with the Poweshell folks lately.  A rash of “examples” of how Powershell is so much easier, because you can do something in “one line” in Powershell that takes you 10-15 lines to do in VBScript.

Most recently from this blog:

[guid]((([directoryservices.directorysearcher] “(samaccountname=theuser)”).findall())[0].properties.getenumerator() | ? { $_.name -eq “objectguid”}).value[0]

Seriously, even in the blog post, he had to give instructions for what this thing means. 

One Response to “It’s not a "one-liner" if…”

  1. Laura said

    Amen. It’s Computer Programming 101 – just because you can make a line of code shorter through nesting (in this case, 4 parenthesis deep), doesn’t mean that you should if it will sacrifice readability/maintainability, particularly if your code is going to be managed/maintained by someone other than you. (And when in a modern workplace is that not going to be the case?)

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>