Powershell

How to Use Get-Member (Microsoft.PowerShell.Utility) Cmdlet in PowerShell?

The “Get-Member” cmdlet in PowerShell gets the properties, methods, and members of objects. It is extremely helpful during the time user is working with some unknown objects. As it gives information about the available methods and properties. It has various parameters that are used to get the customized set of results.

This post will overview PowerShell’s “Get-Member” cmdlet in-depth.

How to Use the “Get-Member” (Microsoft.PowerShell.Utility) Cmdlet in PowerShell?

To get the members, methods, or properties of an object, first, place the “Get-Member” cmdlet along with the “|” pipeline and specify the cmdlet to get the members.

To understand the concept more clearly, check the given examples!

Example 1: Use the Cmdlet “Get-Member” to Retrieve the Members and the Details of Process Objects

First, specify the particular cmdlet to get the members of process objects. Then, pipe it to the “Get-Member” cmdlet:

Get-Process | Get-Member

 

Example 2: Use the “Get-Member” Cmdlet to Get the Extended Members of Process Objects

By using the above-provided command, add the “-View” parameter and assign it the “Extended” value to get the extended list of members:

Get-Process | Get-Member -View Extended

 

Example 3: Use the “Get-Member” Cmdlet to Get the Members for an Array

Initially, create an array variable having the stated values. Then, place the array variable and pipe it to the “Get-Member” cmdlet:

$array = @(1,'apple','mango','banana')
$array | Get-Member

 

Example 4: Use the “Get-Member” Cmdlet to Get the Script Methods of Event Log Objects

Run the given command to retrieve the script methods of event log objects in PowerShell:

Get-WinEvent -LogName System -MaxEvents 1 | Get-Member -MemberType Methods

 

That’s all! You have learned about the cmdlet “Get-Member” with multiple examples.

Conclusion

The cmdlet “Get-Member” is used in PowerShell to retrieve the properties, methods, and members of a specified object. It also reveals the available methods and properties. This post has demonstrated the “Get-Member” cmdlet in detail.

About the author

Muhammad Farhan

I am a Computer Science graduate and now a technical writer who loves to provide the easiest solutions to the most difficult problems related to Windows, Linux, and Web designing. My love for Computer Science emerges every day because of its ease in our everyday life.