PowerShell Genie

Get-Member tutorial: inspect PowerShell objects

Find the property or method a command actually returns before building a filter around it.

Lesson 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Overview

You want the processes consuming the most memory, but you do not know whether the property is called Memory, WS or WorkingSet64. Inspect one result with Get-Process | Get-Member, then read the property names rather than guessing from the column headings.

Get-Member -MemberType Properties narrows the list to data you can select or compare. Methods are operations on the object and can have side effects; a method name appearing in the list is not a reason to call it.

For collections, piped input normally exposes the members of the individual items. Get-Member -InputObject $items instead inspects the collection object itself. If your lookup returned no items, piping it to Get-Member cannot reveal a type that was never returned.

A remoting result may be deserialized. Its properties can remain useful while methods from the original live object are absent. Inspect the returned type in the session where you plan to use it.

What happens

Run the process example and look for WorkingSet64. Then use it in a Select-Object or Sort-Object pipeline. In real PowerShell, inspect Get-Process | Select-Object -First 1 | Format-List * to see values as well as names.

Worth remembering

Get-Member describes an object; it does not retrieve missing data or preserve the input for the next stage.

Primary documentation

Microsoft Learn: get-member

Try it

Browser simulation · fictional data; no changes to your computer.

Interactive simulation · fictional data

Reports the type and full member list of a process object.

Show reference output

Sample output · fictional data, shaped like the real thing

Name          MemberType
------------  ----------
CPU           Property  
Id            Property  
Name          Property  
ProcessName   Property  
WorkingSet    Property  
WorkingSet64  Property  
WS            Property  

Practise this

Discover service properties

Use Get-Member to list the available service properties.

Review the lesson

Keep going

Next: Variables
Genie guideGet-Member tutorial: inspect PowerShell objects

Find the property or method a command actually returns before building a filter around it.