Learning PowerShell by Reinventing the Wheel

Back in 2011 when I started learning how to code in PowerShell, my initial thought to writing a script was to Google search something like “Create AD users from a CSV file” and then grab a script from somewhere and modify it for my environment. I don’t have anything against this actually once you have a solid foundation of learning, although this can be a hindrance in learning to code, at least in my experience. It was quick and sometimes it worked fine for a script I needed to use, but instead of this I decided to start creating scripts from scratch.

While your employer may not be on board with this method at first, in the end it will pay off. Sure, it’s easy to grab a script off the internet, but building your own forces you to learn more of the details of PowerShell. You will undoubtedly run into errors and have to troubleshoot, which enables you to understand PowerShell scripting at a deeper level.

The same goes for modules. Chances are if you are looking for a module for technology X, you will find it in the PowerShell Gallery. Although, this doesn’t necessarily mean it’s a great module or that you can’t create a better one. Even better, perhaps you can contribute to that project.

The community consensus is usually “don’t reinvent the wheel” by creating the same module/script that already exists in the wild, but for learning purposes I could not disagree more. To hell with code already exists. Taking that script and modifying it won’t make you learn, you will just continue to search for crap on the internet until you find something that works for you. Start from scratch, learn, improve and become a better coder.

One Response to “Learning PowerShell by Reinventing the Wheel

  • I completely agree with you!

    Reusing can make you gain time (despite understanding and modifying existing code can also be time-consuming).
    Writing the code from scratch makes you practice and inscribe deeper your knowledge in your brain.

    One way to keep the balance is to first try to figure things out by yourself and then to compare it with others have done.
    After that, you can choose if you want to reuse something existing or build something new.

Leave a Reply

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