Aug 07 2017
Software

Learn Powershell Scripting Basics in 3 Steps

Code your way around repetitive tasks with this scripting language.

Windows PowerShell, the command line shell and scripting language for system administrators, has become the de facto standard for automating just about every Microsoft product imaginable. It’s even made its way to Linux. The ability to automate a variety of tasks and processes has become a critical skill for IT professionals, so there’s no better time to embrace the PowerShell command line and start learning how to script.

Everyone learns PowerShell differently, but I recommend a ­three-step approach to master this scripting language: explore, train and build.

SIGN UP: Get more news from the EdTech newsletter in your inbox every two weeks!

1. Explore the Features of the Scripting Language

The first step is to simply open a PowerShell console and use your current knowledge to see how the console responds. Just type anything; for now, it doesn’t matter what. As you have questions, use the Get-Help command freely. PowerShell’s help system is a wonderful resource and can give the beginner a wealth of information. Also, check out the Get-Command cmdlet, which shows all the commands available to you. Do any look interesting? Try them out and see what happens. You probably aren’t going to break anything.

2. Train to Get Comfortable with PowerShell Basics

Next, take some form of training, whether self-guided or an instructor-led class. If you choose the self-training route, consider the following resources:

These resources will introduce you to PowerShell and get you comfortable with the basics, such as what the console looks like, how it behaves and PowerShell syntax.

3. Build a Solution for a Real Problem

You’ve gotten your feet wet and have a few hours of training under your belt. Now it’s time to build your first useful script. It’s crucial to learn PowerShell by doing, and this is one program where tinkering pays off. For scripting and automation concepts to sink in, and to help your brain digest what’s possible with PowerShell, you must apply your newfound knowledge to a real-world task. You’ll make lots of mistakes, which is normal, but learning how to fix those mistakes will solidify your understanding.

Pick a real task that you believe is ripe for automation. Choose something small that you do repetitively, following the same actions every time. Tasks like creating user accounts or provisioning mailboxes are great starter tasks. Try to use PowerShell to accomplish a task that you’ve always done in a graphical user interface.

Keep this code handy as you start to build your script library. Use these early efforts as a springboard to create larger, more complex scripting tools for your environment. Before you know it, you’ll have mastered the art of automation with PowerShell.

jossdim/thinkstock
Close

Become an Insider

Unlock white papers, personalized recommendations and other premium content for an in-depth look at evolving IT