Basic Powershell: Get-Command, Get-Help, Get-Member

Basic Powershell: Get-Command, Get-Help, Get-Member

This article is part of the series "Basic Powershell". Check out the rest:

In this post we’re going to learn three very useful cmdlets: get-command, get-help, and get-member. This very basic foundation language will eventually empower us execute task-based cmdlets.

By the way, PowerShell is fundamentally case insensitive. There are instances when you’ll need to pay attention to how you type them, like with Active Directory Services Interface, so we’ll cover this another time.

Okay, let’s get started!

Get-Command

get-command outputs all commands available to you in your current session.
Try it! Type:
get-command

get-command

But other than that, using the get-command by itself isn’t particularly helpful. You’re most likely going to use get-command to find commands you’ll want to work with.

For instance, if you want to find all the commands that begin with the letter “s”, type:
get-command s*commands that start with s

In our last post, we mentioned that PowerShell cmdlet names are based on “verb-noun” template. So to see all cmdlets that use the verb get, type:
get-command -verb get

Get-Command -Verb Get

I got excited about this function and tried a few more commands. Join me for some fun?  To see all the things you can start, type:
get-command -verb start

start

And to see all the things you can stop, type:
get-command -verb stop

stop

Let’s do the same thing with noun!  It’s very helpful because it outputs a set of commands that affect the same type of object. For example, if you want to see which commands are available for managing services, type:
get-command -noun service

noun service

Get-Help

Let’s face it, we all need a little help sometimes. For a list of all available help topics, type:
get-help *

gethelp-

Once you have this list, you can then get help on a specific cmdlet. Try this:
get-help get-service

gethelp getservice

Remember our last lesson? You can display the same output if you type -? after the cmdlet. See for yourself! Type:
get-service -?

getservice-

And now for my favorite part! If you ever need an example to see how to use a cmdlet, type:
get-help get-service – examples

get service examples

While my screenshoot displays five, there are a total of eleven get-service examples.

Get-Member

get-member pulls more information about an object. To see what the get-member can do, type:
get-help get-member -examples

get-member1

While my screenshoot displays five, there are a total of seven get-member examples.

In the examples, you’ll notice that you’ll often need to use get-member with a pipeline.

Let’s go over an example. If you want to know which properties and methods are available for event logs, you’d type:
get-eventlog -list | get-member

get member event log

get-eventlog cmdlet enables you to manage your event logs, and enables you to get at the events contained within those event logs

-list is a parameter

Spoiler alert: in upcoming posts we’ll work our way up to use get-member to view properties of Active Directory users. But for now, let’s call it a day.

To Review

Today we learned three major PowerShell commands: get-command, get-help, get-member. You’re now empowered to find a command you might not remember, “get-help” when you need it, and how to get more information on an object.

Now go practice!

Next Time

Let’s work on some task-based cmdlets so you can see what you can really do with PowerShell.

Get the latest security news in your inbox.