How to Use Get-Member in PowerShell: Syntax and Examples
Use
Get-Member in PowerShell to list the properties and methods of objects. Pipe any object to Get-Member to see its members, helping you understand what you can do with that object.Syntax
The basic syntax of Get-Member is:
Get-Member [-InputObject] <PSObject>: Gets members of a specific object.Get-Member [-MemberType] <String[]>: Filters members by type like Property, Method, etc.Get-Member [-Name] <String>: Shows members with a specific name.
You usually use it by piping an object to Get-Member.
powershell
Get-Process | Get-Member
Get-Item C:\Windows\System32 | Get-Member -MemberType Property
"Hello" | Get-Member -Name LengthExample
This example shows how to use Get-Member to find out what properties and methods the Get-Process cmdlet returns. It helps you see what information you can access or what actions you can perform on those objects.
powershell
Get-Process | Get-Member
Output
TypeName: System.Diagnostics.Process
Name MemberType Definition
---- ---------- ----------
Equals Method bool Equals(System.Object obj)
GetHashCode Method int GetHashCode()
GetType Method type GetType()
ToString Method string ToString()
... (many more properties and methods listed) ...
Common Pitfalls
One common mistake is running Get-Member without piping an object, which returns no useful information. Another is expecting Get-Member to show values instead of member names and types. Also, filtering by -MemberType requires exact member type names like Property or Method.
powershell
Get-Member
# Correct usage:
Get-Process | Get-Member
# Filtering by member type:
Get-Process | Get-Member -MemberType PropertyQuick Reference
| Parameter | Description |
|---|---|
| -InputObject | Specify the object to examine directly. |
| -MemberType | Filter members by type (Property, Method, NoteProperty, etc.). |
| -Name | Show members with a specific name. |
| -Force | Show all members, including hidden or private ones. |
| -Static | Show static members of a type. |
Key Takeaways
Pipe any object to Get-Member to see its properties and methods.
Use -MemberType to filter members by type like Property or Method.
Get-Member helps you understand what you can do with PowerShell objects.
Always pipe an object to Get-Member; running it alone shows no members.
Use -Name to find a specific member by its name.