PowerShell Get-Help Cmdlet

PowerShell Get-Help CmdletWindows PowerShell Get-Help

My goal on this page is to explain Get-Help’s hidden but useful nuances.

The examples are designed to help intermediate scripters delve deeper into PowerShell’s capabilities.

 Windows PowerShell Get-Help Topics


PowerShell Cmdlet Litmus Test

Amateurs: Use Get-Help to get an overview of what a cmdlet does.
Professionals: Scan Get-Help’s screens noting parameters’ attributes.

Structure of PowerShell’s Get-Help

  • Synopsis
  • Syntax – Cmdlets often have 2 or 3 layouts.
  • Description – Clues how to use a new cmdlet.
  • Parameters – The most interesting part.
  • Inputs – Does it accept piped entry?
  • Outputs – The type of object returned.
  • Notes – Aliases and default values for output.
  • Examples (If you append -full or -example).

Learning About Get-Help’s Syntax

In this example we just use Get-Eventlog as a vehicle for learning about Get-Help.

# Typing this cmdlet on its own results in an error

Cmdlet Get-EventLog at command pipeline position 1
Supply values for the following parameters:

The problem, Get-Eventlog is asking us for an input (LogName).  Suppose we don’t know the precise logname?  Let us call for:

# Cmdlet help with examples
Get-Help Get-Eventlog -full

Get-EventLog [-Logname] <String> [[-InstanceId] <Int64[]>] ….

— But Get-Eventlog also has a second usage —

Get-EventLog [-AsString [<SwitchParameter>]] [-ComputerName <String[]>] [-List [<SwitchParameter>]] [<CommonParameters>]

We have learned at least two pieces of scripting information:
a) Get-EventLog needs a -Logname parameter.
b) Get-EventLog is really two commands, firstly, displaying the contents of a named log. Secondly, discovering the names of the logs by simply appending the -List parameter thus:

# Get a list of available logs
Get-Eventlog -List

Guy Recommends:  SolarWinds’ Log & Event Management ToolSolarwinds Log and Event Management Tool

LEM will alert you to problems such as when a key application on a particular server is unavailable.  It can also detect when services have stopped, or if there is a network latency problem.  Perhaps this log and event management tool’s most interesting ability is to take corrective action, for example by restarting services, or isolating the source of a maleware attack.

Yet perhaps the killer reason why people use LEM is for its compliance capability, with a little help from you, it will ensure that your organization complies with industry standards such as CISP or FERPA.  LEM is a really smart application that can make correlations between data in different logs, then use its built-in logic to take corrective action, to restart services, or thwart potential security breaches – give LEM a whirl.

Download your FREE trial of SolarWinds Log & Event Management tool.

Parameters (Also Called Arguments or Switches)

The reason you called for help is probably to check the names of the parameters.  Once I show you what to look for, it only takes a few extra seconds to scan a parameter’s attributes, and this knowledge gleaned from Get-Help could save you 10 minutes of fruitless scripting.

Our Vehicle is Get-Help Get-Eventlog.  
Here is a selection of parameters with notes on what to look for in their capabilities.

-After <DateTime> At first glance you probably overlooked the <Type> definition in brackets, but now in future you will absorb this extra information.

In this example, knowing that -After expects <DateTime> will alert you to researching the format, especially if you get an error.  Get-Date may give you clues whether to use dd/mm/yy or mm/dd/yy.

ComputerName <String[]> Clearly this indicates a parameter that accepts names such as BigServer, subtely, the square brackets tells you that you could type multiple names separated by commas. -ComputerName [BigServer, LittleServer]

-List [<SwitchParameter>]  This is a tricky ‘Type’ to understand at first.  At it’s simplest <SwitchParameter> means the value for this parameter is ‘false’, unless you explicitly set a value.

Newest <Int32> Means a number!

Five Attributes of a Parameter

Not all attibutes will have useful or interesting information, but there is usually one item that gives you ideas for using the underling cmdlet more effectively.

  • Required – True / False
  • Position – Named [Or Number]
  • Default Value – LocalComputer
  • Accept pipeline input – True (ByPropertyName) or (ByValue)
  • Accept wildcard charachters – True / False

Accept Pipeline Input

Pipeling (|) is PowerShell’s signature tune.  You may have used $_. to denote ‘in this pipeline’.  In a nutshell, if ‘Accept pipeline input is true’, pipeling will work with this parameter.

There are two options for pipeline input, ByPropertyName means it will accept all PowerShell objects, whereas, ByValue means that it will only accept integers as used by -ID parameters.

# PowerShell script to list parameters with ByPropertyName
Get-Command -CommandType cmdlet `
| Select -Expand ParameterSets | Select -Expand Parameters `
| Where {$_.ValueFromPipelineByPropertyName} `
| Sort-Object -Unique name `
| FT Name, ParameterType, ValueFromPipeLineByPropertyName -AutoSize


Guy Recommends:  A Free Trial of the Network Performance Monitor (NPM)Review of Orion NPM v11.5 v11.5

SolarWinds’ Network Performance Monitor will help you discover what’s happening on your network.  This utility will also guide you through troubleshooting; the dashboard will indicate whether the root cause is a broken link, faulty equipment or resource overload.

What I like best is the way NPM suggests solutions to network problems.  Its also has the ability to monitor the health of individual VMware virtual machines.  If you are interested in troubleshooting, and creating network maps, then I recommend that you try NPM now.

Download a free trial of Solarwinds’ Network Performance Monitor

Update-HelpPowerShell Get-Help Update-Help

Once you find PowerShell v 3.0 on your computer, before you do anything else, you need to run the Update-Help cmdlet.  What this does is populate, then refresh the local cmdlets’ functions and concept help files.

Should You Use Plain Help or Get-Help?

The rule is if the script is only for your eyes suit yourself, but if colleagues are involved then avoid all PowerShell aliases and use the full cmdlet.  Incidentally, Get-Help has it’s own parameters and I always append -full to see Microsoft’s examples for a particular cmdlet.

Researching PowerShell’s About_ Concepts

Conceptual topics begin with ‘About_xya.  For instance, About_Foreach displays information about constructing loops. 

Get more help on PowerShell’s About_ files »

Summary of PowerShell’s Get-Help

Instead of using Get-Help merely to list the parameters.  I want show you how studying the attributes can teach you the principles behind PowerShell.  For instance, pipelining and objects.  Knowledge of a parameter’s properties will also help you write tighter code.

If you like this page then please share it with your friends


See more Microsoft PowerShell tutorials

PowerShell Tutorials   • Introduction   • PowerShell 3 New Aliases   • -Online   • 3 Key Commands

Top 10 PowerShell Aliases   • PowerShell Alias   • PowerShell $_ Variable   • Free CSV Import Tool

PowerShell Parameters   • Cmdlet scripts   • Vista PowerShell   • Windows 8 PowerShell 3.0

Please email me if you have a better example script. Also please report any factual mistakes, grammatical errors or broken links, I will be happy to correct the fault.