Search
  • Nathan

A Quick Primer on PowerShell's shell environment

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:

#List the Modules currently installed on your system:
Get-Module -ListAvailable

#Install a new Module (by default, this pulls from the PS Gallery):
Install-Module -Name <module>

#List all the Commands that come from a particular Module:
Get-Command -Module <module>

#List ALL Commands available on the system:
Get-Command

#View info about a particular Command, including its source Module:
Get-Command <command>

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.

#List all Commands which use the verb Get:
Get-Command -Verb Get

#List all Commands which use the noun Item:
Get-Command -Noun Item

#List all possible verbs:
Get-Verb

PowerShell Objects


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:

<command> | Get-Member
  • 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:

Get-Help -Name <command>

#View the online documentation:
Get-Help -Name <command> -Online

#Get more verbose help information:
Get-Help -Name <command> -Full


Viewing version information:

#There is a built-in variable that stores version info, simply type:
$PSVersionTable

  • The line for PSVersion will show you the currently installed version.

  • 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.

14 views