The Essential PowerShell Primer for 2021
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 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 2021.
Getting Started with PowerShell
Right now, there are two main versions of PowerShell you need to know about: 5.1 and 7.1. 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.1 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.1 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.1 are both relevant, while ones covering Core or 6.0 are not.
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.
“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.”
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.
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.
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.
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.
- 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.
- 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.
- Official Microsoft Azure cmdlets to manage resources in Azure. This module is compatible with Windows PowerShell and PowerShell Core.
- 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.
We’ve identified 3 types of tools: IDEs (Integrated Development Environment), Modules, and Repositories
- Analyzes code and provides coding assistance, error analysis, and smart auto-complete
Sapien PowerShell Studio
- Visually create PowerShell GUI Tools
- Interactive learning (walkthrough) to assist in learning PowerShell. Pre-loaded script library
- Build web-based tools
PowerShell Pro Tools
- Add on Visual Studio. Suite of tools
- Get parameter completion for native Unix utilities. Requires zsh or bash
- Module designed to provide a crash-course intro to PowerShell with programming koans
- Allows administrators to manage their AWS services from PowerShell. Note: Consider installing the individual AWS.TOOLS modules needed.
- Serialize and deserialize yaml
- Commands for discovering, installing, updating and publishing the PowerShell artifacts like Modules, DSC Resources, Role Capabilities and Scripts.
- The Puppet dsc module manages Windows PowerShell DSC (Desired State Configuration) resources.
Here’s a collection of handy scripts that beginners can utilize to help springboard your PowerShell usage.
- PowerShell for Every System
- Azure PowerShell
- PowerShell Functions and Scripts (Azure, Active Directory, SCCM, SCSM, Exchange, O365, …)
- Curated list of delightful PowerShell modules and resources
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
Certified Top Blogger:
Mike F. Robbins
- 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
- Blog by Jeff Hicks, long time PowerShell MVP and professional admin
- Practical how-tos for administrators
- Section for PowerShell tips and tricks- Especially useful for junior developers/ admins
- PowerShell Tips & Tricks • Jeffery Hicks (jdhitsolutions.com)
- Tutorials for admins, such as Convert to Local Time with PowerShell • The Lonely Administrator (jdhitsolutions.com)
- Also has printed books
- In depth introduction to PowerShell
- YouTube videos of the guides
- 11-time Microsoft MVP
- Pluralsight Courses
- Mainly focusing on Azure and DevOps solutions
- John Savill – YouTube
- PowerShell Master Class – PowerShell Fundamentals – YouTube
- Getting Started with Azure PowerShell – YouTube
- Author of 8 Books
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. The ones worth noting are:
Adam the Automator
- DevOps and automation-focused blog
- Dedicated PowerShell section with how-tos and tutorials
- Getting Started with PowerShell and Regex (adamtheautomator.com)
- How to use PowerShell to Get a Registry Value (PS Drives and .NET) (adamtheautomator.com)
Channel 9: Videos for developers from the people building Microsoft Products & Services
- Independent blog by Microsoft employees about various technologies, including PowerShell
- Easy-to-follow videos about PowerShell
- PowerShell v5 Classes :: Object Constructors | PowerShell | Channel 9 (msdn.com)
- Feels more like a hobby project. Good video content but not much PowerShell recently
- 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.
Eye on Tech
- Variety of videos – not just technical. Everything from introductory PowerShell to SWOT Analysis.
- What is Windows PowerShell? An Introduction – YouTube
- Really straightforward introductory videos.
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. While 2021 has seen most events canceled or postponed around the world, these 2 events are scheduled for this April/June and will be 100% virtual.
PowerShell + DevOps Global Summit 2021 April 27-29, 2021
- 100% Virtual This Year
- Tickets for past events $1700 USD This year’s tickets are $300 USD
- Attendees can take part in Q&A
- Lightning Demos – “rapid fire, short 5 – 8 min. demos”
- All sessions will be available on-demand for Summit attendees for an additional 12 months.
PowerShell Conference Europe 2020 June 2-3, 2021
- 100% virtual this year
- Europe’s largest PowerShell-themed annual conference
- Focus on practical advanced PowerShell topics.
- 1 speaker per 10 “delegates” – very intimate experience
- Sponsored by Microsoft
- YouTube channel with previous year’s talks.
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.