Get the properties and methods of object(s).
Syntax Get-Member [ [-name] string[] ] [-inputObject psobject] [-View {Extended | Adapted | Base | All}] [-memberType memberType] [-Force] [-static] [CommonParameters] Key -name The names of one or more properties or methods of the object. Get-Member gets only the specified properties and methods. If you use -Name parameter with -MemberType, -View, or -Static, Get-Member gets only the members that satisfy the criteria of all parameters. To get a static member by name, use: -Static -Name -inputObject psobject The object(s) to retrieve information about. -memberType Get only members with the specified member type. The default is All. valid values: AliasProperty A property that defines a new name for an existing property. CodeMethod A method that references a static method of a .NET Framework class. CodeProperty A property that references a static property of a .NET Framework class. Event Indicates that the object sends a message to indicate an action or a change in state. MemberSet A predefined collection of properties and methods, such as PSBase, PSObject, and PSTypeNames. Method A method of the underlying .NET Framework object. NoteProperty A property with a static value. ParameterizedProperty A property that takes parameters and parameter values. Property A property of the underlying .NET Framework object. PropertySet A predefined collection of object properties. ScriptMethod A method whose value is the output of a script. ScriptProperty A property whose value is the output of a script. All Get all member types. Methods Get all types of methods of the object (for example, Method, CodeMethod, ScriptMethod). Properties Get all types of properties of the object (for example, Property, CodeProperty, AliasProperty, ScriptProperty). Not all objects have every type of member. If you specify a member type that the object does not have, PowerShell returns a null value. To get related types of members, such as all extended members, use the View parameter. If -MemberType is combined with -Static or -View, Get-Member will get members that belong to both sets. -Static Get only the static properties and methods of the object. Static properties and methods are defined on the class of objects, not on any particular instance of the class. If -Static is used with -View, the -View parameter is ignored. If -Static is used with -MemberType, Get-Member gets only the members that belong to both sets. -View PSMemberViewTypes Get only particular types of members (properties and methods). Specify one or more of the values. The default is "Adapted, Extended". Valid values are: Base Get only the original properties and methods of the .NET Framework object (without extension or adaptation). Adapted Get only the properties and methods defined in the PowerShell extended type system. Extended Get only the properties and methods that were added in the Types.ps1xml files or by using the Add-Member cmdlet. All Get the members in the Base, Adapted, and Extended views. The -View parameter determines the members retrieved, not just the display of those members. To get particular member types, such as script properties, use -MemberType. If you use -MemberType and -View in the same command, Get-Member gets the members that belong to both sets. If you use -Static and -View in the same command, the -View parameter is ignored. -Force Add the intrinsic members (PSBase, PSAdapted, PSObject, PSTypeNames) and the compiler-generated get_ and set_ methods to the display. By default, Get-Member gets these properties in all views other than "Base" and "Adapted," but it does not display them. CommonParameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, -WarningAction, -WarningVariable, -OutBuffer -OutVariable.
Standard Aliases for Get-Member: gm
Using the -InputObject parameter is not the same as piping an object to Get-Member:
- When a collection of objects are piped to Get-Member, Get-Member gets the members of the individual objects in the collection, such as the properties of the integers in an array of integers.
- When -InputObject is used to submit a collection of objects, Get-Member gets the members of the collection, such as the properties of the array in an array of integers.
Examples
Display the properties of a Process object:
PS C:\> get-process | get-member -MemberType property
Display the properties of an Alias object:
PS C:\> get-alias | get-member
Display the value of the PSBase property of the Schedule service:
PS C:\> (get-service -schedule).psbase
Display the script properties of event log objects in the System log:
PS C:\> get-eventlog -log system | gm -membertype scriptproperty
Piping a command into get-member twice will display the properties of the parent object: PowerShell.Commands.MemberDefinition:
PS C:\> get-process | get-member | get-member
Prefixing the pipelined input with a comma will also force get-member to run against the container object:
PS C:\> $alias = get-alias
PS C:\> ,$alias | get-member
"I wouldn't join any club that would have me as a member" ~ Groucho Marks (describing Hillcrest Country Club)
Related PowerShell Cmdlets:
Add-Member - Add a member to an instance of a PowerShell object.
Get-Help - Open the help file.
Get-Command - Retrieve basic information about a command.
Get-PSDrive - Get drive information (DriveInfo).