Windows PowerShell Get-Member Cmdlet

Introduction to Windows PowerShell Get-Member

Get-Member is an essential command for discovering more about a PowerShell objects.  Because you are at the command line, you cannot right-click an object and check its properties; instead, what you can do is type: Get-ObjectXYZ | Get-Member.

PowerShell is sometimes referred to as a self-describing language.  Indeed, it is thanks to Get-Member that we can see the properties and methods associated with any given object.

Topics for PowerShell's Get-Member


The Concept Behind Get-Member

The reason that I use Get-Member at every opportunity is so that I can discover 'handles', which help me achieve a particular scripting task.  These 'handles' or memberTypes are split into methods and properties.  Suitable objects to learn more about Get-Member include, service, process, eventlog, or WmiObject.

Here are three examples to illustrate my research technique:

# Results: A long list of Windows services

Get-Service | Get-Member
# Result: A comprehensive list of properties and methods

Get-Service messenger | Get-Member
# Reveals more properties specific to the messenger service

PowerShell Tip - use the tab for Auto-completionTry judicious use of 'tab' and invoke Auto-completion, for example try, Get-p [Tab].  If you press tab again PowerShell cycles through commands beginning with Get-p, for example Get-Process, Get-PSDrive

The Basics of Verb-ObjectXYZ | Get-Member

Employing Get-Member is a useful tactic in the bigger game of scripting specific properties.  For example, if your goal is to stop, or to start a service, then you need to investigate the scripting properties, and possible values, for that service.  A little research with Get-Member will reveal a property called 'Status', with values of 'Running' or 'Stopped' - perfect for our task.

Naturally, the phrase Get-Member never varies, a case of learn once and apply to many objects.  Just remember the hyphen, and also remember that there are no spaces in Verb-Noun pairs. 

Troubleshooting Get-Member

Correct Syntax:  Get-Member

Incorrect Syntax: get member (no hyphen), or get -Member or even Get- member (spaces)

As I mentioned earlier, when you use Get-Member in conjunction with other commands such as Get-ObjectXYZ, remember the 'Pipe' or 'Pipeline' symbol.  This vertical line | is ASCII 124, but looks like this at the PS Prompt  ¦

Correct Sequence: Get-ObjectXYZ | Get-Member 

Incorrect Syntax: Get-Member | Get-ObjectXYZ (Get Member should receive the output)
Trap:  Get-Member Get-ObjectXYZ (Forgot the pipe |)

Guy Recommends: Free WMI Monitor for PowerShellSolarwinds Free WMI Monitor for PowerShell

Windows Management Instrumentation (WMI) is one of the hidden treasures of Microsoft's operating systems.  Fortunately, SolarWinds have created a Free WMI Monitor so that you can discover these gems of performance information, and thus improve your PowerShell scripts.

Take the guess work out of which WMI counters to use when scripting the operating system, Active Directory, or Exchange Server. Give this WMI monitor a try - it's free.

Download your free copy of WMI Monitor

More Examples of Get-Member

# PowerShell's Get-Member with WMI classes
Get-WmiObject Win32_processor | Get-Member

Note 1:  Get-Member is even more useful with WmiObject because its object classes vary more than objects such as Service, Process or Eventlog.  In the above example Win32_processor is the WMI class.

PowerShell Tip - Try alias such as gwmiTry aliases, for example gwmi for Get-WmiObject.  Many people use the alias 'gm' instead of the full cmdlet: 'Get-Member'.

Get-Process | Get-Member

Get-Eventlog system | Get-Member

Note 2:  Get-Eventlog | Get-Member would be incorrect.  If you don't tell PowerShell which eventlog you want, the command does not complete.  The log in the above example is 'System', you could substitute 'Security' or 'Application'.  For a full list try: Get-Eventlog -List.

Filter Get-Member with -Membertype

Results from the simple command: Get-Member, may produce too many MemberTypes; if so, then you can filter the output with a -Membertype argument, for example:

Get-Process | Get-Member -Membertype property
# or
Get-Process | Get-Member -Membertype method

Appreciate that the results of the parameter -MemberType are grouped into at least four categories:  AliasProperty, Method, Property and ScriptProperty.  Once you have researched -MemberType, you may see new applications for the properties that it reveals, for example

Get-Process | group company

Strictly speaking, the above command should be, 'group-Object company', however, 'group-Object' has an alias, thus you can shorten the command to plain 'group'.

Here is a method for expanding the company information:

Get-Process | sort company | ft -group company name, description -auto

Note 3: ft is an alias for Format-Table.

Incidentally, this whole page of -Member examples gives valuable experience of when to use the hyphen - also called a dash, and sometimes referred to as a minus sign.  For example -Membertype takes the hyphen prefix, whereas property, as in -Membertype property does not need any prefix.

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

Get-Member Alias GM

With Microsoft, there are always at least three ways of doing everything, what seems like redundancy when you are an expert, seems like perspective when you are a beginner.  One obvious example is that you can abbreviate Format-Table to ft.  As you increase your range of PowerShell commands, keep an eye out for another PowerShell Alias, for example gci (Get-Childitem).

Getting Help for Get-Member

For a complete list of filters supported by the Get-Member command, call for help thus:

# Help for PowerShell Get-Member
Get-Help Get-Member -full

This may be just me, but I have the urge to call this -method instead of -Member.  I mention this because you always learn more from mistakes.  The answer lies in, a) Reading the error message!  b) Trying an example you know works, for example, I was trying this:

Here is a mistake that I made:

Get-WmiObject win32_computersystem | Get-method

When I read the error message it said: 'Get-method is not recognised'.  Hmmm... I thought, let me try an old friend the process object.

When I tried
Get-Process | Get-method and this also failed, I realized that I was having a 'senior moment'.  Fortunately I woke up and read the error message slowly. 'Get-method is not recognised'.   Ah ha, Get-method is what's wrong, why don't I try Get-Member.  Perfect, it worked just as I wanted.  Thank you error message.

Guy Recommends:  SolarWinds' Free Bulk Import ToolFree Download Solarwinds Bulk Import Tool

Import users from a spreadsheet.  Just provide a list of the users with their fields in the top row, and save as .csv file.  Then launch this FREE utility and match your fields with AD's attributes, click and import the users.

Optionally, you can provide the name of the OU where the new accounts will be born. Download your FREE bulk import tool.

If you need more comprehensive application analysis software,
Download a free trial of SAM (Server & Application Monitor)

New Get-Member Parameters in v 2.0

Two new parameters are -view and -force.  In truth, I have yet to find a cmdlet where researching with these new parameters makes a difference.

Get-Member -Static

Get-Member has a switch to display just static properties.  It's only useful on certain objects, for example, [DateTime]

# Example of Get-Member -Static
[DateTime] |Get-Member -MemberType Property -Static

MaxValue Property static System.DateTime MaxValue {get;}
MinValue Property static System.DateTime MinValue {get;}
Now Property System.DateTime Now {get;}
Today Property System.DateTime Today {get;}
UtcNow Property System.DateTime UtcNow {get;}

Get-Help and Get-Member Working in Tandem

Remember that Get-Help and Get-Member are complimentary.  On the one hand, Get-Help will disclose information about parameters or switches that you can employ with your command, for example -recurse with Get-Childitem -path and -pattern with Select-String. 

On the other hand, Get-Member will disclose the properties and methods, for example .extension .fullname both of which are useful with Get-Childitem.  My point is that Get-Help and Get-Member each provide different information; they are complimentary rather than interchangeable.  If you are complete beginner, investigate both Get-Help and Get-Member; when you are an intermediate don't get fixated on one, and forget all about the other.

More Examples of Get-Member

Summary of PowerShell's Get-Member

When you need to investigate the methods and properties available to a PowerShell object, then call for Get-Member. You will soon get used to its hyphen and associated 'Pipe' symbol (|), just remember the correct sequence: Get-ObjectXYZ | Get-Member.

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


See more PowerShell examples for syntax advice

PowerShell Syntax  • PowerShell Array  • PowerShell Array String Conversion  • Plist

Get-Date  • PowerShell Quotes  • PowerShell variables  • RegEx  • PowerShell functions

• PowerShell Tutorials  • Conditional operators  • PowerShell Hashtable   • Windows PowerShell

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.



Custom Search

Site Home

Guy Recommends: WMI Monitor for PowershellSolarwinds WMI Monitor

Windows Management Instrumentation (WMI) is most useful for PowerShell scripting.

SolarWinds have produced this Free WMI Monitor to take the guess work out of which WMI counters to use for applications like Microsoft Active Directory, SQL or Exchange Server.

Download your free copy of WMI Monitor

Author: Guy Thomas Copyright © 1999-2016 Computer Performance LTD All rights reserved.

Please report a broken link, or an error to: