In this three-part blog series, we’ll solve the mystery of PowerShell and explain how to use it with JumpCloud. In Part 1, we’ll cover some history and give an overview of how you can use shells to automate processes and reduce the time you spend on routine tasks across your environment.
Shell Shock: History of Shells
Starting in IT (or in the world of technology), more and more technologists have become accustomed to an easy-to-follow and intuitive user interface. Look at any program or platform today and you’ll likely find a wide variety of visually captivating interfaces, intuitive reports, and interactive graphics. Although UIs make many tasks easier and are great for productivity, many tasks can only be done from the command line.
In the early 1990s, UIs were available but basic — think Windows 95 on a 10-inch CRT monitor in greyscale. Although UIs were the way of the future in those times, many generations of admins can relate to the old-school world of CLI, Unix systems, and DOS/C/K/Bash shells. Back in the day, this was the only method to interact with applications, systems, and platforms.
For newer admins and technologists accustomed to modern operating systems, the shell and command-line interfaces can create anxiety, hesitation, and habits of avoidance. The goal of this series is to make PowerShell less scary by giving you fundamental skills to help you get work done faster.
What the Heck is a Shell?
Programs and operating systems (OS) at their core are just many, many lines of code. The shell is just one way of interacting with the operating system or different resources within the OS. Shells can be either command-line interfaces (CLI) or graphical user interfaces (GUI). It is the outer interface (shell) to interact with the core OS or application.
If you used computers in the late ‘80s to early ‘90s and ran a command line interface-only machine, that in its basic definition was interacting with a shell. Unix and Linux systems had variants of Bash, C shell, K shell, or Bourne shell (with many other alternatives as well). Microsoft had command line interfaces on its much older OSs, and then the shell took a new facade with releases of NT 3.5 and more widely adopted Windows 95 — the GUI.
GUIs started to replace command-line shells and became more common as the years went by. More and more admins and users alike rarely, if ever, touched the CLI if a GUI was present. These powerful and magical tools started to be put to the side, and the IT engineers and admins who could wield the CLI and scripting could be considered your office’s wizards.
Utilizing the shell — whether it be through PowerShell, bash, or Bourne — gives increased potential to any admin wanting to automate their day. Think of trying to make changes across several hundred objects. Would you really want to do this via the GUI for each object? Using a shell to script changes en-masse can achieve your task in fractions of the time it would take using a GUI or conventional method. With a command or two, you can change attributes across hundreds of objects within seconds, not hours.
With the modernization of many realms of IT, we can easily demystify the lost art of the shell.
Understanding Shell Syntax
Each OS has its own shell(s) and only listens to specific dialects through the shell. This dialect can be called the syntax. Syntax is the language used to form written commands in the shell. Think of the way that you write a sentence in English. For example, Subject → Verb → Predicate, with some other variables, such as a direct or indirect object thrown about.
Writing shell commands and scripts is much like writing sentences, using syntax as the building blocks just like you would words and phrases. Here’s an example of a PowerShell command for use in the JumpCloud Directory Platform, as well as its associated syntax:
Notice in this example, the syntax “sentence” begins with the initial command, Get-JCUser, which serves as the “subject” for this sentence. Variables like the UserID and String act as modifiers, which you use to specify which object you would like the command to act on. Other parameters, such as the -ByID and CommonParameters allow you to more finely control your query or action. Using a command like this one allows you to pull information from your directory and make changes at scale, automating processes that take significantly more time when performed manually.
Going Further into PowerShell
In the next installment in this series, Part 2: the Power of PowerShell, we’ll dive deeper into PowerShell syntax, and how you can use shells to streamline management of Windows, Mac, and Linux devices. You can find Part 2 here.