fbpx Learn About Types and Objects | Windows PowerShell, Windows Server | HostingUltraso.com
24/7/365 Support

Learn About Types and Objects

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.

Help Category:

Get Windows Dedicated Server

Only reading will not help you, you have to practice it! So get it now.

Processor RAM Storage Server Detail
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 128 GB (SSD SATA) Configure Server
Intel Atom C2750 2.4 GHz 8c/8t 8 GB DDR3 1× 1 TB (HDD SATA) Configure Server
Intel Xeon E3-1230 v2 3.3 GHz 4c/8t 16 GB DDR3 1× 256 GB (SSD SATA) Configure Server
Intel Atom C2350 1.7 GHz 2c/2t 4 GB DDR3 1× 250 GB (SSD SATA) Configure Server

What Our Clients Say