A Quick Primer on PowerShell's shell environment
Updated: Aug 27, 2022
Microsoft defines PowerShell as being made up of three main components. First, it is a modern command shell. However, instead of simply accepting & returning text like most shells, PowerShell accepts and returns .NET objects. Second, PowerShell is a robust scripting language. Third, PowerShell can be used as a configuration management framework using PowerShell Desired State Configuration (DSC).
This article is a super quick primer on part 1, the shell. After reading this, you should have all the basic commands you need to find your way around the shell. This is by no means a full guide to using the shell. My intent is to show you a few commands that you can use to get started on the right foot.
Integration with .NET
PowerShell is tightly integrated with NET Framework. For example, PowerShell 5.1 requires NET Framework 4.5. Since NET Framework 4.5 is Windows only, that means PowerShell 5.1 is also Windows only. That’s why you’ll see PowerShell versions 5.1 and earlier referred to as Windows PowerShell.
Microsoft switched things up starting with version 6. PowerShell 6 and later is built on the cross-platform, open-source versions of .NET. That means PowerShell 6 and later can be installed on Windows, macOS, and Linux.
PowerShell Modules & Commands (cmdlets)
PowerShell works via “Modules.” Quite a few Modules come pre-installed for your basic PowerShell commands. You can also install extra Modules for even more functionality. One of the most common repositories for Modules is the PowerShell Gallery.
Each Module contains its own sets of “Commands” (aka cmdlets) that you can run. For example, if you install the “Az” module, you can then use the included Commands to manage resources in Azure.
Here are some examples dealing with Modules & Commands:
The names of the PowerShell commands are structured as verb & noun combos. For example, with the command Get-Help, “Get” is the verb and “Help” is the noun.
As stated earlier, PowerShell deals with .NET Objects instead of plain text. To see all of the details about the .NET Object that a particular command generates, then pipe that command to Get-Member, like so:
This will show you “TypeName” which is the type of the .NET Object being returned.
It will also show you other things associated with this object, like events, methods, properties, etc.
Other useful tips
Getting help on a Command:
Viewing version information:
In the output, the line for PSVersion will show you the currently installed version.
In the output, the line for PSEdition will show as “Desktop” for versions 5.1 and earlier, and it will show as “Core” for versions 6 and 7.