Are You a PowerShell Script Kiddie?

3/9/2016

Keyboard

Take a look at the following five bits of PowerShell code.

Get-Process | Select name,vm,pm,@{label=“TotalMemory”; Expression={$PSItem.vm +$_.pm}}

Get-Process | Select name,vm,pm,@{n=“TotalMemory”; e={$PSItem.vm +$_.pm}}

Get-Process | Select name,vm,pm,@{n=“TotalMemory”; e={$_.vm +$_.pm}}

Get-Process | Select name,vm,pm,@{n=“TotalMemory”; e={$_.vm +$PSItem.pm}}

Get-Process | Select name,vm,pm,@{label=“TotalMemory”; expression={$PSItem.vm +$PSItem.pm}}

Hopefully your head isn’t spinning.

Without actually running them in PowerShell can you answer the following questions?

  1. What will be the results of the first command?
  2. What is the difference between the first and second commands?
  3. What does the @ symbol mean in each command?
  4. If you ran all five commands in a row what would be the change in output between each command?

In security circles the term “script kiddie” refers to a person who downloads scripts and code in order to conduct an attack. The script kiddie doesn’t write scripts or really know how the scripts work.

What about you?                             

In PowerShell we often deal with simple one line commands like the list above. Those commands include mandatory parameters, optional parameters, parameters which are numbered or positional and parameter sets. Oh, and those are just a small part of what you may need to do the most basic of PowerShell activities.

Many sites do a great job of supplying you with entire PowerShell scripts to do complex tasks such as create and modify Group Policy Objects, add new servers to your domain (along with the required roles and features), gather information from thousands of computers and export it to a file for later reporting, etc.

Do you know how those scripts work?

If not then you are a PowerShell script kiddie (except you don’t use PowerShell to conduct attacks…I hope).

But I Don’t Have Time

If you are like me you have a LOT to do. Beyond the projects you are supposed to be working on you put out many fires. You know some PowerShell, but it’s mostly self-taught and just the minimum required to do a specific task. You don’t really understand all of the syntax and symbols and sometimes it’s just faster to revert to the graphical tools you’ve used comfortably for years.

The Power of PowerShell

That’s one of the beauties of Windows; you can open up a GUI (graphical user interface) tool and see current settings and make changes. It’s fairly easy to find a setting (either by working through the tool or doing a Bing search) and in just a few clicks make the desired change.

Let’s use a real life example. Many IT admins have to create new user accounts in Active Directory. If you start on a domain controller with Server Manager open it requires 10 clicks (I counted) to create a new user in an Organizational Unit. Continuing the example perhaps you create three new users on average each day. At first you think, “Well, it’s just a 10 clicks.” But if adding the user (or whatever change you need to accomplish) takes 10 clicks AND you have to do it 3 times each day that’s 30 clicks. Per day. In a work week you are at 150 clicks. If you work 50 weeks per year you’re at 7,500 clicks.

Maybe you are ok with the 10 clicks. But for me, I see the 7,500.

Did you know you could write a single PowerShell command ONCE that removes all of the clicks (except for the one to open PowerShell)? You could set it so the command prompts you to type in the person’s name, OU and password. Or you could just take that information straight from a text or comma separated file.

If you get a bunch of new employees how long will it take you to click through the GUI tool for each person? With PowerShell I can create a thousand accounts in less time than it takes me to create ONE account in the GUI.

That’s a single example of the power of PowerShell to save you time in repetitive tasks. There are hundreds more you could dream up yourself…if you just had a little bit more knowledge of how PowerShell works.

Getting You Up to Speed

At LRS Education Services we’re passionate about helping you do your job more efficiently with lower stress and fewer mistakes. One way we can do that is to offer you the opportunity to sign up for our Microsoft Official Course MS10961B – Automating Administration with Windows PowerShell. In the course you will learn the basics of PowerShell and how to immediately begin implementing it in your environment. It’s well worth your time…and we have different options based on your needs,

The course is available to take live in a classroom in either our Springfield or Bloomington, IL education facilities. You could also sign up to take it virtually and remain in the comfort of your home or office. Finally it’s on our new Microsoft on Demand list, which means you take the class on your schedule, whenever is convenient for you. You have access to the same labs, expert online pre-recorded video content and get added to our Technology Community Hub on Facebook. The hub has our instructors as members who can answer questions as well as other students who are IT professionals like yourself.

 

If you really want to be able to use PowerShell then just downloading a few scripts and playing with them isn’t the most efficient solution. Taking the time to dive in deeper will pay off greatly in the long run. So check with your manager and let them know you’d like to help the bottom line by saving time and effort on mundane tasks. Then you can get back to all those great projects!