PS#2: Three Core Cmdlets – Part 1: “Get-Help”


Proverbs 28:2 (NIV)

“When a country is rebellious, it has many rulers, but a ruler with discernment and knowledge maintains order.”


Purpose:

This three-part post aims to showcase the three core cmdlets in PowerShell & relies on this Microsoft documentation as it’s main source.

Part #1 of 3 will focus on using & installing the “Get-Help” cmdlet for PowerShell.


“Cmdlets” in PowerShell are “compiled commands”.

“Cmdlets” are built on a common runtime, as opposed to separate executables. The advantage of building on a common runtime is “a consistent experience in parameter parsing & pipeline behavior.”

The core cmdlets are built into .NET Core & are open-source. However, you can even build your own cmdlets in .NET Core & PowerShell.

According to Microsoft, the term “PowerShell command” can describe a cmdlet, function, or alias.


“Cmdlets” follow a Verb-Noun format. They often take an object input & return objects.

This article will expand upon the first of these these three cmdlets which follow the verb-noun format.

(1): “Get-Help”

(2): “Get-Command”

(3): “Get-Member”


(1): Using The “Get-Help” cmdlet


The “Get-Help” command mainly helps you learn how to use commands & displays information about these commands.

Here is what PowerShell 7.1 says about it’s “Get-Help” cmdlet:

What PowerShell 7.1 says about it’s own “Get-Help” cmdlet.

The output of the various “Get-Help” command parameters will not be the entire help article available, only what is available by default.

Technically, the “Get-Help” command can help you locate commands, but it’s primary purpose is to help you use a command once it is already located.

Installing Help

PowerShell version 3.0 and beyond, do not have help content preinstalled or packaged.

When you run “Get-Help” in PowerShell for the first time, you will get a similar message to this one.

Installing Help content on PowerShell 7.

Typing “Update-Help” can locate and install the necessary Help content with a working Internet connection.

*** You likely will need to be using PowerShell with Administrator privileges for the “Update-Help” command to work.***

After running the “Update-Help” you may get an error message asking you to run a command similar to “Update-Help -UICulture en-US”; this may or may not fix the modules that did not correctly install. In my case, it did not.

“Update-Help -UICulture en-Us” command to fix error after “Update-Help”.

To test if your install works, try entering “Get-Help NAME” on the PowerShell CLI.

“Get-Help NAME”

Another common issue I came across is the “Get-Help” cmdlet resulting in only partial help.

For instance:

Partial Help from “Get-Help Get-EventLog”.

However, the cmdlet “Get-Help Get-EventLog -Online” took me right to the Microsoft Documentation I needed for Get-EventLog.

***You may have to change the version of PowerShell in the dropdown menu on the Microsoft Website.

Changing the PowerShell version in the Microsoft Learn Documentation after entering “Get-Help Get-EventLog -Online”.

Parameters & Syntax


Commands in PowerShell often require Parameters.

Parameters allow you to specify options & arguments that can alter the behavior of a command.

The SYNTAX section of the particular help article demonstrates the available parameters.

If we use the cmdlet: “Get-Help Get-EventLog”, we see this SYNTAX section listed.

The “[ ]” square bracket pairs can have TWO different purposes:

(1) Elements inside the “[ ]” are optional

OR

(2) An empty set of “[ ]” following a datatype, will indicate that the parameter accepts multiple values which are either an array or a collection object.

In the above example, the (1) optional elements are:

In the above example, (2) with the datatypes are:


Positional Parameters

The “Get-EventLog” cmdlet uses a concept called positional parameters.

A positional parameter allows you to enter a value without specifying the name of the parameter, but it must be entered in the correct position on the command line.

This positional information is located in the PARAMETERS section of the cmdlet’s help article.

—Example—

“Get-Help Get-EventLog -Full” — The cmdlets with the Blue boxes & blue arrows are positional parameters.

***If you specify the parameter name explicitly, you can utilize the parameter out of it’s order/ in any order.***


!!! Helpful Tip !!!

If you utilize the “help” function, you can slow down the rate at which the “get-help” cmdlet delivers information. You will control the rate at your pleasure.

For Example: “help Get-Help -Full”

The “– More –” allows you to press ENTER to control the rate of information flow on your screen.

The next article in this three-part PowerShell series will focus on the “Get-Command” cmdlet.

For more information on the “Get-Help” cmdlet, please read this Microsoft Documentation.



All PowerShell posts here.

PowerShell#1 blog-post here: Installing PowerShell on Windows.

Proverbs 28:2 (NIV)

“When a country is rebellious, it has many rulers, but a ruler with discernment and knowledge maintains order.”



Comments

One response to “PS#2: Three Core Cmdlets – Part 1: “Get-Help””

  1. […] Part 1 of this 3-part post focused on the “Get-Help” cmdlet. […]

Leave a Reply

Your email address will not be published. Required fields are marked *