What Does PowerShell Get-Member Do?

Stewart Beam

What Does PowerShell Get-Member Do?

The Get-Member Command provides a why to see what type of object a given PowerShell command produces. It provides the ability to determine what other properties an object might have that we don’t see when we run the command.

Why does the Object Type matter?

We won’t go into detail here, but in general when using the pipeline to send output of one command to another command the type can matter. This will generally be more important when writing our own tools and moving data between tools. For the purpose of this post just knowing where to find the information is enough.

In the output below we ran Get-Process and then sent the command to Get-Member. In the output we see the TypeName: at the very top. The object type being produced by the Get-Process Command shows as System.Diagnostics.Process.

Using Get-Member to find Object Properties

In the image below we have just ran the Get-Process Command and are showing the 8 headers used in the columns. These are the default properties that our command is producing. That isn’t the number of properties available for the object though.

How Many Properties are actually available?

Just as a quick example we output the Get-Member information for Get-Process to a file and then read that contents to measure the number of lines. It says 95, but we don’t actually have 95 properties. Some of those are methods or events. We can see that it even if we were to sort it and eliminate non-properties we would be well over the 8 we show in our default format.

Here we can see an excerpt of some of the other available properties. If there is something else we need to know about the process we can use these properties to pull up specific information.

Using a Non-Default Property to Get Information

We are getting the standard output for Get-Process for an openvpn process.

Now we use use the non-default Path property to see the path to the executable for this process. The output was sent to a list instead of a table just to make the it more readable. This one might not seem too exciting, but as we need to work with commands the need to pull in additional properties can present itself.