Posey's Tips & Tricks

What's the Best Way To Learn PowerShell?

Simply experimenting with an existing PowerShell script is an effective way to build expertise. Just make sure to do it inside a virtual machine.

Although Windows PowerShell is an unbelievably useful and powerful tool, it can be difficult to master. There are lots of little nuances that can cause PowerShell to behave in a way that is completely unexpected. Never mind the fact that new cmdlets are being added to PowerShell all the time.

So what's the easiest way for a busy IT pro to learn all of the ins and outs of PowerShell?

Before I answer this question, it's worth considering why you want to learn PowerShell. If your only reason is that you need it to accomplish a particular task, you may be better off doing a Web search for whatever it is you are trying to do. I certainly don't want to discourage anyone from learning PowerShell, but if you only need it for a one-off task, chances are someone has else already written a PowerShell script that does whatever it is you need to do. You may be able to save yourself a lot of time and effort by downloading a prebuilt script.

On the other hand, if you really do want to learn PowerShell, it's worth considering the learning method that you find to be most effective. Everyone learns in different ways. Some people learn best by sitting through a PowerPoint presentation, while others might learn best by reading about a given subject. If you fall into one of these categories, there are plenty of excellent books and video-based courses that can help you learn PowerShell.

Other people (myself included) find hands-on learning to be the best approach. Unfortunately, it can be a bit tougher to find good-quality hands-on labs, although they are out there if you look hard enough. That being the case, I wanted to share with you the method I used to learn PowerShell and other programming languages. It's a bit unorthodox and it definitely needs some explaining, but I wanted to put it out there in case anyone can benefit from it.

When I was a kid, I really wanted to learn how to write computer programs. Unfortunately, I didn't have access to a computer, let alone books on programming. One day, a friend gave me an old RadioShack Color Computer (or CoCo, as it was known back then). The CoCo, like so many other computers of the time, booted directly into a command interpreter that you could use to write programs.

Back then, if you bought a computer, it usually came with a couple of books that were designed to teach you how to write programs. However, I had acquired my computer secondhand and the guy who gave it to me couldn't find the books that went with it. That meant I faced the monumental challenge of trying to figure out how to program my new computer without the aid of any sort of reference manuals.

One of the things that was so unique about that particular time was that there were lots of magazines written for computer enthusiasts. These magazines typically included lots of source code. For instance, a magazine might publish the source code for a video game, a printer utility or something like that. All you had to do was type it into your computer without making any mistakes in the process.

At any rate, I managed to get my hands on one of those magazines and tried out a couple of the programs. Once I got a program to work, I would start making changes to the program just to see what would happen. I might delete a line of code, rearrange lines of code or change some of the values used within a command. At first these changes were completely random because I didn't know what I was doing, but over time, I began to get a feel for what the various commands did. That was how I learned programming.

Obviously, things are a lot different today. Microsoft provides online documentation for all of the PowerShell cmdlets. Even so, documentation can be somewhat cryptic, especially for someone who has not yet mastered the basics of PowerShell.

When I was first learning PowerShell, I used an approach that was very similar to what I used to do when I was a kid. I would take short blocks of code that I found on the Microsoft Web site and make experimental modifications to the code. Between that and looking up the syntax of unfamiliar cmdlets, I was able to learn PowerShell relatively quickly.

Obviously, this method isn't for everyone because we all learn in different ways. However, if you are someone who learns by doing, then simply experimenting with an existing PowerShell script can be a very effective way to build expertise. Just make sure to do any experimentation inside of a virtual machine (preferably with no network access) so you don't risk breaking anything on your production machine.

About the Author

Brien Posey is a 22-time Microsoft MVP with decades of IT experience. As a freelance writer, Posey has written thousands of articles and contributed to several dozen books on a wide variety of IT topics. Prior to going freelance, Posey was a CIO for a national chain of hospitals and health care facilities. He has also served as a network administrator for some of the country's largest insurance companies and for the Department of Defense at Fort Knox. In addition to his continued work in IT, Posey has spent the last several years actively training as a commercial scientist-astronaut candidate in preparation to fly on a mission to study polar mesospheric clouds from space. You can follow his spaceflight training on his Web site.

Featured

comments powered by Disqus

Subscribe on YouTube