Member type in PowerShell (ScriptProperty, Property, and NoteProperty)
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:
- Using
Add-Member
(giving maximum control) - Specifying additional properties by passing a hash rather than a name to
Select-Object
's property parameter - Using
New-Object
to create aPSObject
and passing - In .NET code (C#, VB, …) using the underlying
PSObject
properties andPSMemberInfo
sub-types.
The different types of "extended" member are represented by those PSMemberInfo
sub-types, including:
- NoteProperty: a .NET object or value.
- AliasProperty: an alias for another property (eg. a collection could have both a Count and a Length property with one being another name for the other).
- ScriptProperty: a property with get and set methods written in PowerShell.
- CodeProperty: a property with get and set methods written in C#, VB, ….
and so forth.
See the PSMemberTypes Enumeration page