Do You Even PowerShell?

Jeff
Tech Jobs Academy
Published in
4 min readMar 1, 2016

PowerShell is an extremely powerful tool if you learn to use it effectively. But assuming you have never used any previous version of PowerShell, it might be difficult to understand the syntax or terminology of it. Working with PowerShell can be a time saver, but first you must learn some basics to utilize it as a tool.

My first experience seeing PowerShell, I was a bit thrown off by its structure. But once I took the time to read and learned some of the formatting, it became easier to understand. Let’s look at some basic syntax of PowerShell pictured below in the screenshot. The command, Get-Service will look up the services running on the client. The “|” symbol is called piping. PS (PowerShell) will take the output of Get-Service and pipe it through the script ‘where-object {$_.status -eq “Running”}’. This script will check for all services where the status is “eq(equal)” to “Running”.

The format PowerShell uses for its cmdlets is a verb-noun syntax. A cmdlet is a lightweight command used in PowerShell. When the verb and noun are joined together it is called a cmdlet and that cmdlet will perform a certain task. For example Get (verb)-Service (noun) will let you view the properties of a service. A few examples of verbs and nouns include:

There are more verbs available to use and depending on the noun you use, there are certain verbs associated with them. There are tons of different cmdlets in PowerShell and it’s impossible to remember them all.

The example I want use to showcase the power and efficiency of PowerShell is managing group memberships. Instead of using the Active Directory Users and Computers prompt to create and add members, we will be using PowerShell commands.

Let’s create a new group named “Server1” in the “IT” organizational unit, scope: global, and group type: security. So instead of using the GUI (Graphical User Interface), we’ll create the group using the cmdlet “New-ADGroup”.

First, let’s open the PowerShell (PS) app, which is usually pinned on the task bar. You can also find it by clicking the Windows icon. Once it’s open, we’re good to go. When creating the group, you will need to include certain parameters to include in the cmdlet such as Name, Path, and Group Scope. Then, enter the command below to see the group created when you navigate to the IT OU (organizational unit).

PowerShell Application

After creating the group, let’s add a new member to the group “Server1”:

And we’re done!

Creating security groups and adding new members are just a fraction of the things that you can do with PS with just a few lines of text in just a few minutes. PS plays a key part in making a System Administrator’s job easier. As you learn PS further, you will learn PS commands to automate tasks such as:

  1. Performing queries to find object properties.
  2. Generating on-demand reports.
  3. Creating and maintaining Active Directory Users and OUs.

PowerShell is a tool I believe every System Administrator or anyone performing tasks in Windows Server should learn. The things PS can do are almost limitless. It might not end up being your go to tool when performing every task, but it will help for the ones you do often. If you want to learn more about PS, check out the links below.

--

--