14.3. Inspecting Properties and Methods
Once you have created a new .NET object, you will frequently want to inspect or change properties of that object or use its methods to carry out specific tasks. One of the major learning tasks if you are new to the .NET Framework is to become familiar with the members of the huge variety of .NET classes. To help you explore, PowerShell provides a cmdlet, get-member, to assist you in finding the members of any .NET class that you need to use.
14.3.1. Using the get-member Cmdlet
The get-member cmdlet is very useful for finding the members of a .NET instance object. In addition to the common parameters, it supports the following parameters:
Name — Specifies what member names are to be selected. A positional parameter in position 1. The default value is the wildcard *, which matches all members.
InputObject — Specifies what object or objects are the input to the cmdlet. Used when the get-member cmdlet is not receiving input objects from a pipeline.
MemberType — Specifies the type of member to be returned. Allowed types are enumerated later in this section.
Static — Specifies that only static members are to be returned
One way to explore the members of the $myDate object is the command
$myDate | get-member
which pipes the $myDate object to the get-member cmdlet. This is equivalent to, but simpler than, the following command:
$myDate| get-member -Name * -MemberType All
The preceding command returns about two screens of members of the $myDate object, ...
Get Professional Windows® PowerShell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.