There used to be a wonderful introduction to MSDN in the extended PowerShell type system (unfortunately, lost with changes from PSH v1).
In essence, PowerShell allows you to wrap a basic .NET object with additional members using PSObject . There are several ways to do this:
- Using
Add-Member (providing maximum control) - Specifying additional properties by passing a hash rather than a name in the
Select-Object property parameter - Using
New-Object to create a PSObject and transfer - In .NET code (C #, VB, ...), using the basic properties of the
PSObject and PSMemberInfo subtypes.
Various types of "extended" elements are represented by these subtypes of PSMemberInfo , including:
- NoteProperty: An object or .NET value.
- AliasProperty: an alias for another property (for example, a collection can have both a Count property and a length, and the other can be different).
- ScriptProperty: a property with get and set methods written in PowerShell.
- CodeProperty: a property with get and set methods written in C #, VB, ....
etc.
source share