PowerShell: What is it & what can you do with it

In today’s age there are a number of ways that one can interact with and manage computer systems, ranging from standard methods like the ubiquitous graphical user interface (GUI), to command line interfaces (CLI) that some might see as a step backward to the age of terminals and green screens. These are further supplemented by additional methods like application programming interface (API) calls and web-based management interfaces.

In order to understand why there has been a shift back towards the command line one must first understand some of the basic necessities when administering computer systems on a large scale. The ability to complete repetitive tasks quickly and accurately is crucial when managing a large number of systems. Furthermore, the capability to ensure that these tasks are done in the same manor each and every time becomes paramount as it ensures that the intended results are attained.

To meet these needs, a common CLI method used today is Microsoft Windows PowerShell. Find out the basics of PowerShell, how it can be used and why it’s becoming more popular for system administrators.

PowerShell… so what is it?

PowerShell is Microsoft’s scripting and automation platform. It is both a scripting language and an interactive command environment built on the .NET Framework. To better understand what PowerShell is, it helps to understand how it’s used. One of the authoritative resources on the subject, Ed Wilson, defines PowerShell as the following:

“Windows PowerShell is an interactive object-oriented command environment with scripting language features that utilizes small programs called cmdlets to simplify configuration, administration, and management of heterogeneous environments in both standalone and networked typologies by utilizing standards-based remoting protocols.”

There’s a lot to that definition so let’s unpack that a little more.

What is object-oriented?

An objected-orientated language can be defined as a form of logic – it’s a way to understand how the platform or language behaves. An object is something that has one or more attributes and one or more methods or functions. Here are some examples:

Think of a television remote control. Its attributes are the size, shape, color, number of buttons, and other things of that nature. Its functions include turning the television on and off and adjusting the volume.

A car is another good example. Its attributes are things like it’s current speed, license plate number or location. Its methods are moving, parking, accelerating or slowing down.

A final example of an object is a dog. Its attributes are mood, color, breed, and energy level and methods are playing, sleeping, barking or chasing a tail.

What are Cmdlets (or Command-lets)?

PowerShell is made up of a collection of commands that carry out particular functions or tasks. On the backside of the cmdlet there are a number of things happening: the command that is executed is working with classes, methods, multiple objects, possible API calls and many other things in order to carry out its job. The advantage of PowerShell is that you don’t have to understand all of these backend principles in depth since the cmdlets take care of those processes.

To assist in the use of cmdlets PowerShell follows a verb-noun naming pattern to help users understand the purpose of the commands. Example verbs include New, Set, Get, Add and Copy. Microsoft has a documented list of approved verbs and their intended uses to help maintain consistency throughout the platform. When placed together with nouns, you get cmdlets such as:

Get-Help
Get-Process
Get-Member

How is PowerShell used?

PowerShell has many uses and often is only limited by one’s creativity. As mentioned earlier, PowerShell functions both as an interactive language as well as a scripting tool. Both use cases allow for easier administration of systems as well as a great deal of flexibility for IT professionals.

When being used as a CLI to interact directly with a system, one of the major benefits of PowerShell is the ability to remotely connect to another system. An administrator can use a remote PowerShell session to connect to a server that’s not in the same physical location and run commands as if he or she were working directly on that server. A broad range of administrative tasks can be done remotely, saving IT professionals hours of time.

It also allows administrators to run the same commands against multiple servers at the same time, providing further time-saving benefits.

When it comes to creating PowerShell scripts, the ability to perform consistent tasks and steps repeatedly is a huge benefit for IT administrators. PowerShell automates many tasks, from the complete roll out of a new server in a virtual environment, to the configuration of new mailboxes in Office 365 and a host of additional functions in-between.

In their simplest form, PowerShell scripts are a collection of PowerShell commands. This makes the transition from working with individual commands in the CLI to a fully automated script straight forward.

What can you do with PowerShell?

Now that you have some basic knowledge of what PowerShell is and how it’s used, let’s explore what you can do with it.

First, it’s important to note that PowerShell is not going away. Despite the move from the olden days of green screens and the CLI to graphical user interfaces for almost everything we do, there is a trend toward moving things back to the CLI. There are many reasons for this, but one centers around the development lifecycle.

GUIs are usually the form of a wrapper that ultimately is running code or commands on the backend when an action occurs like clicking a button. This means that the underlying code still needs to be written for the GUI to function. By cutting out the graphical piece and just using the PowerShell code, companies can more quickly roll out changes and updates without having to worry about also updating and testing a GUI in addition to the code, which is often time consuming.

PowerShell is tightly integrated into almost all of Microsoft’s products. In fact, there are certain actions in popular products like Office 365 and Server 2016 that cannot be done with a GUI and can only be done with PowerShell. Along with being 100% necessary for certain tasks, the ability to automate with PowerShell makes understanding it a worthwhile skill for many IT professionals.

Second, once you start understanding all that can be done with PowerShell, it opens a whole new set of capabilities. From basic automation, to advanced scripting, PowerShell can provide an abundance of opportunities for simplifying tasks and saving time.

In future entries we will look at in-depth uses of PowerShell scripting and how it can be used to simplify many areas of an IT environment including: server configuration and deployment, user creation and auditing and administrative tasks in O365. In the meantime, these resources are a great launching point for learning more about PowerShell.