The Surly Admin

Father, husband, IT Pro, cancer survivor

Powershell – Steep Learning Curve?

This has come up at Spiceworks a couple of times, the which should I learn discussion. vbScript or Powershell? Considering the theme of this blog I don’t think you need to ask which camp I stand in. But what about this steep learning curve? Here are my thoughts.

I don’t think there’s any question that the initial learning curve on Powershell is high. I call it gaining your Powershell eyes. Once you “get” it, it makes sense and you can look at almost any code and know what the writer is trying to accomplish. But without that it can be pretty confusing. Take this snippet taken from Spiceworks, for example:

Get-PSDrive -PSProvider FileSystem | Where-Object {$_.displayroot -notmatch "\\"}

And someone immediately complained that Powershell was too complicated, and I guess it is if you don’t have Powershell eyes.  In my–humble, of course–opinion there is a steep initial learning curve to Powershell, as there are with most scripting/programming languages.  You have to learn usage, syntax, quirks, all of it.  Powershell also has a lot of symbols it likes to use which also make things interesting.  Here’s my view on how learning Powershell looks:

20130323-185136.jpgThere’s a few initial things you can do at the very beginning that’s pretty easy, but after that it gets very difficult and you have to start learning basic Powershell concepts, cmdlets and statements.  But once you start getting those the learning curve falls off a cliff and things get really easy.  This is especially true when you start learning objects and how they can be used, especially with piping them into the cmdlet’s that Microsoft has created.  Once this concept sinks in, at least for me, the vista’s of possibility really opened up and the potential that is in Powershell hit me.

I think the hardest part about getting over that initial hump is knowing which command you can use and where. The other difficult part is so many people love to use alias’ and pack as much functionality into one line as humanly possible. And when you’re looking at that for the first time it can be baffling.  Don’t get me wrong, it’s pretty amazing what you can do with a single line of code, and I’ve been known to string together some scary stuff too, but when trying to first break into Powershell it just makes it hard to follow.

The next most common problem is people with experience with vbScript try to program Powershell just like they did with vbScript, which makes sense. This often ignores the fact that Powershell might have some cmdlets that would highly simplify their coding! The most common example of this is when someone tries to use Powershell to query Active Directory and they break out the tried and true LDAP queries–here’s a recent example of just that.  Again, not saying you won’t ever use LDAP in your Powershell scripts, but there is often an alternative that is much better.

Even reading the help files can be rough as they often vary in how good they explain things and, honestly, some of them are just aweful at explaining what it is a cmdlet can do.

So how do I get over the hump?

Start small.  A lot of people seem to jump straight into Powershell by creating a script to create new users.  It sounds like a simple thing but it’s actually quite involved (here was my take on it, if you don’t believe me).  Instead go for simple things.  How do I list a user’s title and extension?  How do I list all the members of a group?  Things that can be done simply at the command line.

Next find a good community and lurk.  Don’t be afraid to pipe in on a thread though and simply ask a question.  In my experience most Powershell communities are very open and willing to help n00bies out–and don’t be ashamed that you’re a n00b.  Believe me, we all started out there and most people are more than willing to help out.  Check out Spicework’s Powershell forum here, PowerGUI has a pretty good forum here and Powershell.org has a very active forum here.  You’ll find me at Spiceworks and PowerGUI as I found Powershell.org to be too active and overwhelmed me with email!!  For you, that might be a good thing?

One thing that helps me is to keep a “snippet” library of code that you found useful.  I use Evernote to keep everything (and it keeps it synchronized across my computers at home and work) but it started as a simple text file.  When you see a useful bit of code, save it in your library to reuse it, and don’t be afraid to post in a forum about what it does, if there’s some part in it you don’t understand.

And don’t forget, Google is your friend!  Use him!

Of course, it’s possible I might have written about getting started with Powershell too:

How do you start using Powershell?
Powershell Discovery: Variables
Get Started with Powershell: Loops and branches
Powershell and the Pipeline
Powershell Best Practices – Surly Style

I also have an entire series on Powershell Performance that I thought was pretty interesting!

Hopefully this helps you a little bit and gives you some initial guidance on how to get started using Powershell.  It is a journey worth taking and once you get over the initial hump it really will get easier.

Advertisements

March 28, 2013 - Posted by | Powershell - Getting Started | , ,

9 Comments »

  1. Hi Martin, there’s no closing curly brace on that PowerShell snippet. I’m starting to get my Powershell eyes thanks to your examples on SpiceWorks and now glad to know about your articles here. Thanks!

    Comment by Todd6700 | March 29, 2013 | Reply

    • Right you are! See, I left that to see if anyone would catch it. Yeah, honest. What? 🙂

      Comment by Martin9700 | March 29, 2013 | Reply

  2. […] the .NET stuff pretty difficult to work with–which explains why I think the learning curve on Powershell ramps back up as you get more advanced–but sometimes you just have to go […]

    Pingback by Using Powershell as a Telnet Client « The Surly Admin | April 4, 2013 | Reply

  3. […] is, it is pretty hard at first. This particular blog put’s it succinctly (Particularly the […]

    Pingback by Windows Powershell scripting for Beginners Part 1: Introduction | JTechEd – A place for Information Technology education and help, as well as general tech and computer information. | November 13, 2016 | Reply

  4. You might be interesting in my own blog post on the subject. https://outsourcedguru.wordpress.com/2016/02/22/why-powershell-sucks-so-badly/

    Comment by outsourcedguru | April 18, 2017 | Reply

    • *interested*

      Comment by outsourcedguru | April 18, 2017 | Reply

    • Fantastic example of someone who doesn’t know how to use a product complaining about how they can’t use the product. Still, everyone has different interests and capabilities. Some take to PowerShell and others don’t. I do think he should probably try to do the same chore in VBScript, then let us know how much PowerShell sucks! haha

      Comment by Martin9700 | April 18, 2017 | Reply

      • Correct, I don’t know how to use PowerShell. But since I have 36 years as an I.T. administrator & programmer, you’d think that their interface(s) wouldn’t be so cryptic to someone with my experience. Are UNIX shell commands terse? Yes. But it feels to me like the Internet has collected enough examples of UNIX administrative shell script examples and documentation so that I eventually script something that works out. I wouldn’t suggest the same for PowerShell.

        If I complain that Microsoft doesn’t really *get* this (administrative scripting), then when you suggest that I try another Microsoft scripting engine (VBScript) if I don’t like PowerShell, then you aren’t getting the point of my complaint. Microsoft has 70,000 employees and a fair amount of money in the bank. In theory, they have their own “I.T. pain” to solve behind-the-scenes. I’m guessing their own people feel that PowerShell is just too problematic for real support.

        As an I.T. person, I need scripts for my purposes. In some cases, I need users to self-heal a known problem by clicking a link I’ve given them. In some cases, I—the admin—can be there to add some additional credentialing when I’m doing things but sometimes not. It doesn’t sound like PowerShell is the solution for the problems I’m seeing and Microsoft is too scared of their past security mistakes to make the tool easier to use.

        In the past, I wrote a 600-line MS-DOS batch file to build a nightly documentation system for a floor-ful of customer support people. I know my command line and I’m fond of automation tasks. The basics of PowerShell suggest that someone is following along in the footsteps of UNIX scripting and they’ve separated things into data providers and data consumers so that you can Lego-click things together into a stream. That part seems awesome. But I hold firm in my assessment of the dysfunctional credentialing/approval mechanism(s) in place: this is hardly ready for prime-time.

        Comment by outsourcedguru | April 19, 2017

      • “I’m guessing their own people feel that PowerShell is just too problematic for real support.” Simply not true. I invite you to visit PowerShell.org to get a sense for how people feel about it.

        Does it have it’s warts? Of course it does, every language does. But the evidence of it’s adoption rate, especially in the past 5 years, simply doesn’t support your assertions.

        Still, you have to “hike your own hike” and if PowerShell isn’t working for you then by all means use another language. Plenty of things can be installed on Windows and run just fine. With the proliferation of REST and SOAP API’s, the middle layer scripting language simply doesn’t much matter. Since Window’s is primarily an API based system then you can interface pretty much any language with it, you just have to learn the ins and outs of the API. One of the strengths of PowerShell is it’s ability to insulate you from those API’s (by someone else doing it for you and writing a cmdlet!)

        Comment by Martin9700 | April 19, 2017


Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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

%d bloggers like this: