user

The Essential PowerShell Primer for 2024

Introduction

Crista Perlton

Crista Perlton


LATEST POSTS

How Licenses Work with Chocolately 22nd March, 2024

How to Handle npm Dependencies with Lock Files 16th January, 2024

PowerShell

The Essential PowerShell Primer for 2024

Posted on .

Most people AREN’T using PowerShell to its full potential — and if you’re not using its full potential, you’re wasting time and resources. The good news is that your competition is likely doing the same. The best news is that this article can help. 

Have you ever found yourself Googling around for PowerShell resources and finding over nine zillion articles that didn’t answer your questions or were too technical to gain any value from? We have that too. That’s why we created this primer (so you don’t have to).

Below is a concise list of all the terms, tools, and resources needed to create an actionable process improvement plan. This essential PowerShell foundational resource helps you level up your team’s PowerShell game in 2024. 

Getting Started with PowerShell 

Right now, there are two main versions of PowerShell you need to know about: 5.1 and 7.4. Both are actively being used. 

Simply put, 5.1 is focused on a traditional, Windows-focused infrastructure with Windows Servers and PCs. PowerShell 5.1 is the most developed version of PowerShell and offers the most “cmdlets.” This is also the version of PowerShell that comes pre-installed on all Windows PCs. 

PowerShell 7.4 is the evolution of the now-defunct PowerShell Core. This branch introduces compatibility with cloud-based solutions and the ability to run PowerShell on Linux and MacOS. PowerShell 7.4 is close to 5.1 in terms of features and will likely replace 5.1 in the future. 

Note: Articles and documentation covering PowerShell 5.1 and 7.4 are both relevant, while ones covering Core or 6.0 are not. 

Core Concepts 

While this is not a guide on how to write PowerShell, it is important to clarify important core concepts to master. 

Any engineer needs to know these concepts to be able to write efficient PowerShell. While it may be possible to run scripts without knowing what a “cmdlet” is, it is not possible to comprehend what is happening in a script without understanding the structure.  

And any IT manager should at least know the core concepts to be able to make good decisions when planning how PowerShell should be implemented into their teams. Simply knowing that PowerShell exists will not help when it comes to making complex decisions such as deciding policies for how more-perfect scripts should be written. 

PowerShell Runtime 

“The PowerShell” is on any Windows system. It is the environment where all PowerShell scripts are run. Simply, it’s what a computer uses to translate PowerShell to machine code. The PowerShell runtime is also called a “runspace.” 

cmdlets (pronounced “command-lets”) 

The basic building blocks of any PowerShell script used to automate and simplify routine administration tasks across local and remote Windows-based systems are called cmdlets. There are around 200 basic cmdlets, but you don’t need to know all of them. 

While cmdlets are part of PowerShell script files, they can also be typed into the PowerShell command prompt directly to carry out simple commands like “show me files” or “run programs.” 

PowerShell Script 

A PowerShell script is really nothing more than a simple, reusable text file containing a series of PowerShell commands, with each command appearing on a separate line. For the text file to be treated as a PowerShell script, its filename needs to use the .PS1 extension. 

Scripts can be executed directly by right-clicking and selecting “run with PowerShell” or by running the file using the PowerShell built into Windows. 

PowerShell Functions 

Functions are used to create code in small “blocks” to reduce the redundancy of the repeated code. Instead of copy/pasting the same code repeatedly, create a PowerShell function. 

Functions are essentially code collected to perform something one or many different times. Give the function a name and reuse it multiple times by using the name. 

PowerShell Module 

Modules (.psm1 files) allow you to combine like scripts into a single, cohesive package that can be easily shared with other users.  

Users can import your packages into their PowerShell environment to add functionality. Modules can’t be run in the PowerShell but will rather become a part of it. For example, the Azure module allows the PowerShell to manage Microsoft Azure services. 

Think of it like installing a new Wi-Fi adapter in a computer: As soon as the adapter is installed, the computer will have Wi-Fi functionality added.  

A popular place to share modules is Microsoft’s PowerShell Gallery

PowerShell DSC (Desired State Configuration) 

PowerShell DSC provides admins with a way to maintain consistent configuration sets across computers or devices more easily than just using cmdlets. 

Instead of the user instructing Windows how to configure the system, the user specifies a goal for the configuration, and DSC does all the intricate configuration itself. 

DSC is very powerful but highly complex. We’ll revisit the topic in a different article. 

PowerShell Tools 

If you are using PowerShell, these are tools you will more than likely utilize if you are not already using them. There are other options, but these are the major tools. The core tools needed to write PowerShell Scripts are all developed by Microsoft directly and are available for free. 

PowerShell ISE
  • Microsoft’s main tool for running commands, writing, testing, and debugging scripts in a single GUI.  
  • Comes installed with every copy of Windows and supports all versions up to v5.1. 
Visual Studio Code
  • Microsoft’s PowerShell plugin for its popular IDE provides rich PowerShell language support. 
  • Provides additional functionality such as color-coding different parts of script to help with readability. 
PowerShell Gallery
  • Central repository for PowerShell content. 
  • Contains scripts, modules, cmdlets, etc., that add additional functionality to PowerShell. 
  • Content is provided both by Microsoft and through individual user contributions. 

Popular Modules 

AZ
  • Official Microsoft Azure cmdlets to manage resources in Azure. This module is compatible with Windows PowerShell and PowerShell Core. 
Azure PowerShell 
  • A set of cmdlets for managing Azure resources directly from the PowerShell command line. 
AWS Tools for PowerShell 
  • The AWS Tools for Windows PowerShell and AWS Tools for PowerShell Core are PowerShell modules that are built on the functionality exposed by the AWS SDK for .NET. The AWS PowerShell Tools enable you to script operations on your AWS resources from the PowerShell command line. – Modify your AWS resources with PowerShell. 
PowerShell on Google Cloud Platform
  • Cloud tools for PowerShell let you script, automate, and manage your Windows workloads running on GCP. 

After familiarizing yourself with the Microsoft official tools, you may want more out of PowerShell. Below is a small variety of tools for users looking to customize and add to their PowerShell experience. A-la-carte PowerShell tools and solutions. 

Popular Tools

We’ve identified 3 types of tools: IDEs (Integrated Development Environment), Modules, and Repositories 

IDEs

Intellij IDEA  
  • Analyzes code and provides coding assistance, error analysis, and smart auto-complete 
Sapien PowerShell Studio
  • Visually create PowerShell GUI Tools 
IDERA
  • Interactive learning (walkthrough) to assist in learning PowerShell. Pre-loaded script library 
PowerShell Universal
  • Build web-based tools 
PowerShell Pro Tools 
  • Add on Visual Studio. Suite of tools 

Modules 

Microsoft.PowerShell.UnixCompleters  
  • Get parameter completion for native Unix utilities. Requires zsh or bash
  • Single version, released in 2020
PSKoans 
  • Module designed to provide a crash-course intro to PowerShell with programming koans  
AWSPowerShell 
  • Allows administrators to manage their AWS services from PowerShell. Note: Consider installing the individual AWS.TOOLS modules needed.  
  • Last updated in 2020
PowerShell-yaml 
  • Serialize and deserialize yaml 
PowerShellGet
  • Commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts. 
Puppet DSC 
  • The Puppet dsc module manages Windows PowerShell DSC (Desired State Configuration) resources.
  • 5+ years since last updated, most recent version released 2019. 

GitHub Repositories

Here’s a collection of handy scripts that beginners can utilize to help springboard your PowerShell usage.  

PowerShell 
  • PowerShell for Every System 
Azure-PowerShell 
  • Azure PowerShell 
Lazywinadmin 
  • PowerShell Functions and Scripts (Azure, Active Directory, SCCM, SCSM, Exchange, O365, …) 
  • While useful, was last updated 4+ years ago
Awesome-powershell 
  • Curated list of delightful PowerShell modules and resources
  • Another repository that was updated 2+ years ago, but still very useful

PowerShell “People to Know” 

These are PowerShell power-users. They are great sources of information, inspiration, and education. Below are resources for people who are just starting out as well as users who are looking to take their PowerShell usage to the next level.  

PowerShell | Automating the world one-liner at a time
Joey Aiello 
  • Some great posts, but hasn’t posted since 2021
Mike F. Robbins – Scripting | Automation | Efficiency 
  • Former Microsoft MVP, now Senior Content Developer for Azure PowerShell 
  • Mostly complex topics, not focused on new developers or people
The Lonely Administrator
Tech Thoughts
  • In-depth introduction to PowerShell 
  • YouTube videos of the guides 
John Savill

In the world of PowerShell, you’ll most likely run into some of these blogs and individual contributors. These are some great resources for not just PowerShell, but DevOps info too.  

Microsoft PowerShell Community

Different people are active and it’s difficult to determine any minor players. However, many Microsoft employees are active here. While they may not have updated so recently, the ones worth noting are: 

Adam the Automator
Microsoft – Shows
  • Independent blog by Microsoft employees about various technologies, including PowerShell 
  • Easy-to-follow videos about PowerShell 
  • Feels more like a hobby project. Good video content but not much PowerShell recently 
MrPowerScripts
  • PowerShell articles along with Python, Reddit, personal stories, etc. 
  • YouTube PowerShell content along with loads of other random videos including Reddit, personal stories, python, etc. 
  • While articles are still relevant and useful, the last update was in 2021.
     
Eye on Tech

Conferences/Events 

A great way to learn the newest in the world of PowerShell and to get in-depth industry knowledge is through conferences and events. Users that are interested in connecting and learning from industry leaders should look here. 

PowerShell + DevOps Global Summit 2024 April 08-11, 2024 (Bellevue, WA)
  • This year’s tickets are $1999 USD 
  • 50+ speakers
  • “OnRamp”, a class-based program, introducing new IT professionals to the world of DevOps
  • All sessions will be available to the community on their YouTube channel in May 2024. 
  • Twitter 
PowerShell Conference Europe 2024 June 24 -27, 2024 (Antwerp, Belgium)
  • Europe’s largest PowerShell-themed annual conference 
  • Tickets range from $1350 to $1499 depending on number purchased
  • Focus on practical advanced PowerShell topics. 
  • 1 speaker per 10 “delegates” – very intimate experience 
  • Sponsored by Microsoft 
  • YouTube channel with previous year’s talks. 

Power Up!

There’s a lot to learn when it comes to PowerShell but using this essential PowerShell resource, you can save yourself time on your journey as you power up your PowerShell game. For many more ways to give your PowerShell scripts and modules a boost, take a look at our free eBook, “Ultimate Powershell Levelup Guide”. Sign up for your copy today!

Crista Perlton

Crista Perlton

Navigation