PowerShell: Get-Command and Get-Member

Today, I want to show you a couple great cmdlets that can really strengthen your understanding of

PowerShell: Get-Command and Get-Member.

Get-Command will list all commands that are installed on the computer, including cmdlets, aliases, functions, etc.

Try it out. The results should look something like this:

get-command

Get-Command

There’s a lot of output on the screen, so we can clean this up a little bit to make it easier to read.

Let’s say we just want the name of the commands. We’re going to select only one object property by piping the results of Get-Command and selecting the property that we want to see.

Get-Command | Select-Object Name
get-command select-object name

But, how do we know which object properties exist to select and sort? We’re going to introduce another command today called Get-Member.

Get-Member tells us about the Properties and Methods of an object.

The easiest way to use it is to pipe in an object that you want to know more about.

Get-Command | Get-Member
get-command get-member

We can see that there are many properties for Get-Command that we can use to sort and view. Let’s use CommandType and Name.

Get-Command | Select-Object CommandType, Name
get-command select-object commandtype name

You should be able to look at that list and find any cmdlet that’s installed that you can use.

In the next blog, we will go over another tool that will help get more detailed information about each cmdlet from within PowerShell itself.

In the meantime, here’s some more detailed information about Get-Command and Get-Member.