Problem
You have an instance of an object and want to know what methods and properties it supports.
Solution
The most common way to explore the methods and properties supported by an object is through the GetMember cmdlet.
To get the instance members of an object you’ve stored in the $object variable, pipe it to the GetMember cmdlet:
$object | GetMember GetMember –InputObject $object
To get the static members of an object you’ve stored in the $object variable, supply the –Static flag to the GetMember cmdlet:
$object | GetMember –Static GetMember –Static –InputObject $object
To get the static members of a specific type, pipe that type to the GetMember cmdlet, and also specify the –Static flag:
[Type] | GetMember –Static GetMember –InputObject [Type]
To get members of the specified member type (for example, Method, Property) from an object you have stored in the $object variable, supply that member type to the –MemberType parameter:
$object | GetMember –MemberType memberType GetMember –MemberType memberType –InputObject $object
Discussion
The GetMember cmdlet is one of the three commands you will use most commonly as you explore Windows PowerShell. The other two commands are GetCommand and GetHelp.
If you pass the GetMember cmdlet a collection of objects (such as an Array or ArrayList) through the pipeline, PowerShell extracts each item from the collection, and then passes them to the GetMember cmdlet onebyone. The GetMember cmdlet then returns the members of each unique type that it receives. Although helpful the vast majority of the time, this sometimes causes difficulty when you want to learn about the members or properties of the collection class itself.
If you want to see the properties of a collection (as opposed to the elements it contains,) provide the collection to the –InputObject parameter, instead. Alternatively, you may wrap the collection in an array (using PowerShell’s unary comma operator) so that the collection class remains when the GetMember cmdlet unravels the outer array:
PS >$files = GetChildItem PS >,$files | GetMember
TypeName: System.Object[]
Name MemberType Definition
Count AliasProperty Count = Length Address Method System.Object& Address(Int32 ) (...)
For more information about the GetMember cmdlet, type GetHelp GetMember.