Get-Member
Additional Resources for Get-Member |
Listing the Properties and Methods of a Command or Object http://www.microsoft.com/technet/scriptcenter/topics/msh/cmdlets/get-member.mspx
|
SYNOPSIS
Gets information about objects or collections of objects.
SYNTAX
Get-Member [[-name] <string[]>] [-inputObject <psobject>] [-memberType {<AliasProperty> | <CodeProperty> | <Property> | <NoteProperty> | <ScriptProperty> | <Properties> | <PropertySet> | <Method> | <CodeMethod> | <ScriptMethod> | <Methods> | <ParameterizedProperty> | <MemberSet> | <All>}] [-static] [<CommonParameters>]
DETAILED DESCRIPTION
Gets information about the members of objects. Get-Member can accept input from the pipeline or as the value of the InputObject parameter. You can use the MemberType parameter to specify the type of members you want information about.
If you pipeline input to Get-Member, it outputs a MemberDefinition object for each distinct type of input object. For example, if you pipe the output of Get-ChildItemto Get-Member in a directory that includes at least one subdirectory and one file, it returns two MemberDefinition objects. One includes information about the FileInfo object and the other includes information about the DirectoryInfo object. Get-Member outputs only two MemberDefinition objects, regardless of how many files or subdirectories are in the directory.
The output of Get-Member is different if you supply input by using the InputObject parameter. In that case, Get-Member returns a single MemberDefinition object that represents either the single input object or the collection class that contains the set of input objects.
To retrieve information about static members, you must specify the Static parameter.
PARAMETERS
-name <string[]>
Specifies the member names to retrieve information about.
Required? |
false |
Position? |
1 |
Default value |
* |
Accept pipeline input? |
false |
Accept wildcard characters? |
true |
-inputObject <psobject>
Specifies the objects to retrieve information about. Using this parameter to provide input to Get-Member results in different output than pipelining the same input. When you pipeline input to Get-Member, if the input is a container, the cmdlet returns information about each unique type of element in the container. If you provide the same input by using the InputObject parameter, the cmdlet returns information about the container object itself. If you want to use pipelining to retrieve information about a container, you must proceed the pipelined input by a comma (,). For example, if you information about processes stored in a variable named $process, you would type ,$process | get-member to retrieve information about the container.
Required? |
false |
Position? |
named |
Default value |
|
Accept pipeline input? |
true (ByValue) |
Accept wildcard characters? |
false |
-memberType <PSMemberTypes>
Indicates type of members to retrieve information about. Valid member types are: AliasProperty, CodeProperty, Property, NoteProperty, ScriptProperty, Properties, PropertySet, Method, CodeMethod, ScriptMethod, Methods, ParameterizedProperty, MemberSet, and All.
The following lists the acceptable values for this parameter:
· AliasProperty
· CodeProperty
· Property
· NoteProperty
· ScriptProperty
· Properties
· PropertySet
· Method
· CodeMethod
· ScriptMethod
· Methods
· ParameterizedProperty
· MemberSet
· All
Required? |
false |
Position? |
named |
Default value |
All |
Accept pipeline input? |
false |
Accept wildcard characters? |
true |
-static <SwitchParameter>
Specifies that static properties and methods should be retrieved.
Required? |
false |
Position? |
named |
Default value |
False |
Accept pipeline input? |
false |
Accept wildcard characters? |
false |
<CommonParameters>
This cmdlet supports the common parameters: -Verbose, -Debug, -ErrorAction, -ErrorVariable, and -OutVariable. For more information, type, "get-help about_commonparameters".
INPUT TYPE
Any object
NOTES
For more information, type "Get-Help Get-Member -detailed". For technical information, type "Get-Help Get-Member -full". When specifying multiple values for a parameter, use commas to separate the values. For example, <parameter-name> <value1>, <value2>".
EXAMPLE 1
get-process | get-member -MemberType property
This command displays the properties of a .Net Framework Class Library System.Diagnostics.Process object (the type of objects returned by the get-process Cmdlet).
EXAMPLE 2
$alias = get-alias
$alias | get-member
get-member -inputobject $alias
This command displays information about the AliasInfo object that is returned by the Get-Alias cmdlet. It stores the alias information in the $alias variable. The $alias variable is piped to the Get-Member cmdlet to display information about the members of the AliasInfo objects. It then uses the InputObject parameter, supplying the $alias parameter as the value, to demonstrate that when that method of input is used, information about the container object, a System.Object array, is returned.
EXAMPLE 3
get-process | get-member | get-member
This command displays information about the MemberDefinition object returned by Get-Member. The Get-Processcmdlet is used to retrieve a list of processes, which provides input to the first call to Get-Member. The result of that call, a MemberDefinition object, is piped to Get-Member. The result is that information about the members of the MemberDefinition object is displayed.
RELATED LINKS