The (Former) Complexity of PowerShell

  • Steve Jones - SSC Editor - Thursday, January 19, 2017 11:21 AM

    Eric M Russell - Thursday, January 19, 2017 8:16 AM

    PowerShell is an extremely feature rich language; I'll give it that much. But what a dislike about PowerShell is it's syntax. It's a hodgepodge of commands, functions, switches, and pipes.   It's as if the folks who created PowerShell consisted of C++, Visual Basic, and Python programmers who couldn't all agree on what language to standardize on, so they decided to compromise by splitting off into separate teams.
    For example:

    get-process | get-member 
    get-pssnapin | where {$_.vendor -ne "Microsoft"}

    Comparison operators are switches. For example:

    if ("Peter" -gt "Paul")
    {
       ...
    }

    I agree. The -eq gets me constantly. Less now, but I still think in terms of >, <, = rather than switches.<

    I am a little surprised you say that. Have you been using all the different parameters on the Get-Help cmdlet? If in doubt:

    Get-Help Get-Help -Full

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • suparSteve - Thursday, January 19, 2017 1:28 PM

    Steve Jones - SSC Editor - Thursday, January 19, 2017 11:21 AM

    Eric M Russell - Thursday, January 19, 2017 8:16 AM

    PowerShell is an extremely feature rich language; I'll give it that much. But what a dislike about PowerShell is it's syntax. It's a hodgepodge of commands, functions, switches, and pipes.   It's as if the folks who created PowerShell consisted of C++, Visual Basic, and Python programmers who couldn't all agree on what language to standardize on, so they decided to compromise by splitting off into separate teams.
    For example:

    get-process | get-member 
    get-pssnapin | where {$_.vendor -ne "Microsoft"}

    Comparison operators are switches. For example:

    if ("Peter" -gt "Paul")
    {
       ...
    }

    I agree. The -eq gets me constantly. Less now, but I still think in terms of >, <, = rather than switches.<

    One of my goals for the year is to increase my proficiency in PowerShell and I'll agree with the comments about the whacked syntax (being a long-time fan and heavy user of Python for, well, everything I'm not using T-SQL for). It has, in the past, introduced a lot of friction when I try to put a script together, leading to discouragement and sporadic use. The verbose cmdlet names (Get-TheCompatibilityLevelOfThisDatabaseYouSpecified etc) were kind of off-putting, but using something like ISE makes life a bit easier there.

    Coming from the UNIX world I think 'piping full-blown objects, not just text around' is pretty awesome so with a more committed effort perhaps it will become my third or even second favorite language for things.

    Are you aware of TAB completion? Partially enter a cmdlet name and TAB will cycle through the matching cmdlets.

    Gaz

    -- Stop your grinnin' and drop your linen...they're everywhere!!!

  • I'm a late adopter of PoSh and I also kinda shrugged when I first played with it years ago. I'm drinking the Kool - Aid now though. For example,  I've used it to pull data from websites into SQL Server, it's helped me to integrate an EDI and accounting system (basically grabbing files and ETL'ing them into tables)  and just finished a script (SQL Agent job) to restore our production databases and run DBCC CHECKDB against them (including lots of logging for a consolidated report as well as integration with our administrative database). The last one was probably the largest script and it's only about 150 lines of code. It's a little cryptic and touchy but I like how I can mix and match the T-SQL and everything else I want without writing a ton of code to do it. Debugging can still be pain but ... no pain... no gain.

  • I use tab completion heavily as well as Get-Help. However the help isn't well structured of written, IMHO. It reminds me of verbose, poorly structured man pages.

    While I do get more confortable with PoSh, I do still think some of the constructs are rather un-intuitive and cumbersome.

  • I first played with PowerShell when it was in Beta and I was working on an operations team performing tasks that got signed off on a paper checklist.
    First impression:  Wow, this really feels like bash!
    I started using it immediately to automate tasks where I could.

    Now I realize that other shells are mostly just parsing strings.  PowerShell lets me create and access properties of objects.
    It makes me a faster DBA, allows me to prove and share my work (Start-Transcript), and it's quite readable.

    Steve, thank you for your post, and thank you, Mr. Snover!

  • Maybe PowerShell is less complex than it used to be, but it's still far to verbose to be useful.  The interface names are all too long, and so are parameter names.

    Tom

  • Maybe PowerShell is less complex than it used to be, but it's still far to verbose to be useful.  The interface names are all too long, and so are parameter names.

    [/quote]

    Auto complete 😛

  • ZZartin - Friday, May 5, 2017 2:19 PM

    Maybe PowerShell is less complex than it used to be, but it's still far to verbose to be useful.  The interface names are all too long, and so are parameter names.

    Auto complete 😛

    [/quote]
    Auto complete doesn't make your screen any wider.

    Tom

Viewing 8 posts - 16 through 22 (of 22 total)

You must be logged in to reply to this topic. Login to reply