What are the member types in PowerShell, like ScriptProperty, Property, Method, NoteProperty, Alias, and EventProperty?
For example, CPU
is ScriptProperty. How can we classify it as ScriptProperty?
I would like brief information about all of them.
NoteProperties are generic properties that are created by Powershell (as opposed to properties that are inherited from a specific dotnet object type).
The Add-Member cmdlet lets you add members (properties and methods) to an instance of a PowerShell object. For instance, you can add a NoteProperty member that contains a description of the object or a ScriptMethod member that runs a script to change the object.
A script property defines a property whose value is the output of a script. In the following example, the VersionInfo property is added to the System. IO. FileInfo type.
Description. The Get-Member cmdlet gets the members, the properties and methods, of objects. To specify the object, use the InputObject parameter or pipe an object to Get-Member . To get information about static members, the members of the class, not of the instance, use the Static parameter.
There used to be a great introduction on MSDN to the PowerShell Extended Type System (unfortunately lost with the changes since PSH v1).
Essentially PowerShell allows an underlying .NET object to be wrapped with additional members via the PSObject type. This can be done in a number of ways:
Add-Member
(giving maximum control)Select-Object
's property parameterNew-Object
to create a PSObject
and passing PSObject
properties and PSMemberInfo
sub-types.The different types of "extended" member are represented by those PSMemberInfo
sub-types, including:
and so forth.
See the PSMemberTypes Enumeration page
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With