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 outputs all commands available to you in your current session.
Try it! Type:
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.
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-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
get-command -verb start
And to see all the things you can
get-command -verb 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
Let’s face it, we all need a little help sometimes. For a list of all available help topics, type:
Once you have this list, you can then get help on a specific cmdlet. Try this:
Remember our last lesson? You can display the same output if you type
-? after the cmdlet. See for yourself! Type:
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
While my screenshoot displays five, there are a total of eleven
get-member pulls more information about an object. To see what the get-member can do, type:
get-help get-member -examples
While my screenshoot displays five, there are a total of seven
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-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.
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!
Let’s work on some task-based cmdlets so you can see what you can really do with PowerShell.