PowerShell Get-Member Cmdlet
Hello Everyone
Welcome to CloudAffaire and this is Debjeet.
In the last blog post, we have discussed Get-Command cmdlet in PowerShell.
https://cloudaffaire.com/powershell-get-command-cmdlet/
In this blog post, we will discuss Get-Member cmdlet in PowerShell. You can use cmdlet Get-Member to get properties and methods available to a cmdlet. Every cmdlet has some methods available to it which can be used to perform some action using the cmdlet. For instance, Get-Process cmdlet has a method ‘Kill’ which can be used to kill a process. Properties are the information that can be retrieved using the cmdlet. For instance, Get-Process has a property ‘Threads’ which can be used to get thread information of a process.
Using Get-Member cmdlet, you can get all the methods and properties available to a particular cmdlet. Below is the list of members that you can get using Get-Command cmdlet. Not all cmdlet will have all members available to them.
- AliasProperty: An alias to another member
- All: All member types
- CodeMethod: A method defined as a reference to another method
- CodeProperty: A property defined as a reference to a method
- Dynamic: All dynamic members (where PowerShell cannot know the type of the member)
- Event: All events
- MemberSet: A set of members
- Method: A method from the BaseObject
- Methods: All method member types
- NoteProperty: A property defined by a Name-Value pair
- ParameterizedProperty: A member that acts like a Property that takes parameters. This is not considered to be a property or a method.
- Properties: All property member types
- Property: A property from the BaseObject
- PropertySet: A set of properties
- ScriptMethod: A method defined as a script
- ScriptProperty: A property defined by script language
Get-Member Cmdlet Syntax:
1 2 3 4 5 6 7 8 |
## Get-Member ## [-InputObject ## [[-Name] ## [-MemberType ## [-View ## [-Static] ## [-Force] ## [ |
Get-Member Cmdlet Argument List:
- –Force: Adds the intrinsic members and the compiler-generated get_ and set_ methods to the display.
- –InputObject: Specifies the object whose members are retrieved.
- –MemberType: Specifies the member type that this cmdlet gets. The default is All.
- –Name: Specifies the names of one or more properties or methods of the object.
- –Static: Indicates that this cmdlet gets only the static properties and methods of the object.
- –View: Specifies that this cmdlet gets only particular types of properties and methods.
PowerShell Get-Command Cmdlet:
Get All Members Of A Cmdlet In PowerShell:
1 2 3 4 5 6 7 8 9 10 |
###################################### ## PowerShell | Cmdlet | Get-Member ## ###################################### ## PowerShell Latest Version (5) ## get all members of a cmdlet Get-Process | Get-Member Get-Process | Get-Member -View All |
Get Extended Members Of A Cmdlet In PowerShell:
1 2 3 |
## get extended members of a cmdlet Get-Process | Get-Member -View Extended |
Get Specific Members Of A Cmdlet In PowerShell:
1 2 3 4 5 |
## get only methods or properties of a cmdlet Get-Process | Get-Member -MemberType Property Get-Process | Get-Member -MemberType Method |
Get All The Static Members Of A Cmdlet In PowerShell:
1 2 3 |
## get only the static properties and methods of a cmdlet Get-Process | Get-Member -Static |
Get All Members Of A Cmdlet Based On Name In PowerShell:
1 2 3 |
## get members based on certain names Get-Process | Get-Member -Name "*time*" |
Hope you have enjoyed this article. In the next blog post, we will discuss the New-Object cmdlet in PowerShell.
To get more details on PowerShell, kindly follow below official documentation