❑ Type conversion is used after type distance is determined to convert the arguments passed to invoketo the type of parameters needed by the method being called.. class PSPropertySetPSMe
Trang 1Methods are member types that can take arguments, may return some value, normally do significant
work, and cannot appear on the left-hand side of an expression Specifically,PSMemberTypes.Methods
includeMethod,ScriptMethod, andCodeMethodmember types
Methods are accessed from script using the same syntax as other members with the addition of
parenthe-ses at the end of the member name
All methods derive fromPSMethodInfo, which is summarized in Figure 3-14
Figure 3-14: Methods derived fromPSMethodInfo
❑ Invokeis the basic mechanism used to call (invoke) the specified method It is passed in the
argu-ments with which to call the method as an array of objects Note that these arguargu-ments are the
‘‘value’’ only, no name
❑ The order and type of the arguments must correspond to the expected parameters of the
particular method being called Type distance algorithms are used to match the arguments so
that the correct overload is called (see the section ‘‘Distance Algorithm’’ later in this chapter)
❑ Type conversion is used after type distance is determined to convert the arguments passed to
invoketo the type of parameters needed by the method being called
❑ Optional parameters and ‘‘params’’ parameters are considered in the distance algorithm and in
the invocation of the method
Trang 2❑ Valuereturns ‘‘this’’ instance of the derived method type (this approach still enables us to derivefromPSMemberInfo) Note that this is ‘‘sealed,’’ and therefore the derived method types do
not have to deal with this Any attempt to set the value throwsNotSupportedException
❑ OverloadDefinitionsis a collection of strings that state which overloads are available These
contain the complete signature for those methods
The following sections describePSMembersthat derive fromPSMethodInfo
PSMethod
APSMethodis one that is defined on theBaseObjector is made available through an adapter
The definition of aPSMethodis shown in Figure 3-15
class PSMethod
PSMethodInfo
PSMethod
+ Copy() : PSMemberInfo+ Invoke(object[]) : object+ ToString() : string
«property»
+ MemberType() : PSMemberTypes+ OverloadDefinitions() : Collection<string>
+ TypeNameOfValue() : string
Figure 3-15:PSMethod
❑ Invokecalls the underlying CLR method on the adapter orBaseObject If there is more than onedefinition of this method, then thePSMethodInfobase class uses the distance algorithm to deter-mine which one to call
❑ OverloadDefinitionsgets the overloads from the CLR methods of this type using reflection
❑ TypeNameOfValuereturnstypeof(PSMethod).FullName
The following example uses the CLR methodsplitto split a string on semicolons:
Trang 3PS>
PSScriptMethod
APSScriptMethodis an extended member method defined in the PowerShell language It provides
similar functionality to a method on theBaseObject, but it may be added to aPSObjectdynamically
(based on theTypeNamelookup or on anInstance)
The definition of aPSScriptMethodis shown in Figure 3-16
class PSScriptMethod
PSMethodInfo
PSScriptMethod
+ Copy() : PSMemberInfo+ Invoke(object[]) : object+ PSScriptMethod(string, ScriptBlock)+ ToString() : string
«property»
+ MemberType() : PSMemberTypes+ OverloadDefinitions() : Collection<string>
+ Script() : ScriptBlock+ TypeNameOfValue() : string
Figure 3-16:PSScriptMethod
❑ Scriptreturns theScriptBlockthat defines thisScriptMethod
❑ Invokecalls the underlying script block specified in the script
❑ OverloadDefinitionswill always be a collection of 1, asScriptMethodsdo not support
overloads yet
❑ TypeNameOfValuereturnstypeof(PSScriptMethod).FullName
PS C:\> $psobj = new-object system.management.automation.psobject
PS C:\> add-member -inputobject $psobj -membertype noteproperty -name DevCost -Value 2
PS C:\> add-member -inputobject $psobj -membertype noteproperty -name TestCost -Value 4
PS C:\> add-member -inputobject $psobj -membertype scriptmethod -name RealCost -Value {
Trang 4APSCodeMethodis an extended member method defined in a CLR language It provides similar
func-tionality to a method on theBaseObject, but it may be added to aPSObjectdynamically (based on the
TypeNamelookup or on anInstance)
In order for aPSCodeMethodto become available, a code developer must write the method in some CLRlanguage, compile it, and ship the resultant assembly The assembly must be available in the runspace
where the code method is desired
The definition of aPSCodeMethodis shown in Figure 3-17
class PSCodeMethod
PSMethodInfo
PSCodeMethod
+ Copy() : PSMemberInfo+ Invoke(object[]) : object+ PSCodeMethod(string, MethodInfo)+ ToString() : string
«property»
+ CodeReference() : MethodInfo+ MemberType() : PSMemberTypes+ OverloadDefinitions() : Collection<string>
+ TypeNameOfValue() : string
Figure 3-17:PSCodeMethod
❑ Invokecalls the underlying CLR method specified in theCodeReference
❑ OverloadDefinitionsgets the overloads from the CLR methods of this type using reflection
❑ TypeNameOfValuereturnstypeof(PSCodeMethod).FullName
The following example shows the code necessary to create aCodeMethodthat computes theRealCost
given amultiplierand aPSObjectthat contains aTotalCostproperty:
public class CodeMethodScheduleCost
Trang 5PSOb-There is currently no mechanism to create overloads (therefore, theOverloadscollection is always of
length 1)
Assuming that the assembly which implementsRealCostis available on this runspace:
PS C:\> $psobj = new-object system.management.automation.psobject
PS C:\> addmember inputobject $psobj membertype noteproperty name DevCost
-Value 2
PS C:\> addmember inputobject $psobj membertype noteproperty name TestCost
-Value 4
PS C:\> addmember inputobject $psobj membertype scriptproperty name TotalCost
-Value {$this.TestCost + $this.DevCost}
APSParameterizedPropertyis how ETS exposes COM parameterized properties to the developer and
engine It combines parts of both a property and a method It derives fromPSMethodInfobecause usage
has shown this to be most effective (because anything taking arguments requires an ‘‘invoke’’-style
member instead of just a simple get/set interface) The definition of aPSParameterizedPropertyis
«property»
+ IsGettable() : bool+ IsSettable() : bool+ MemberType() : PSMemberTypes+ OverloadDefinitions() : Collection<string>
+ TypeNameOfValue() : string
Figure 3-18: Definition of aPSParameterizedProperty
Trang 6❑ Constructoris not public because a user may not create one of these It is only exposed if an
adapter provides it
❑ Invokecalls the underlying COM parameterized property ‘‘getter’’ with the arguments
passed in
❑ OverloadDefinitionsgets the overloads from the COM properties of this type usingIDispatch
andTypeLibraries
❑ InvokeSetcalls the underlying COM parameterized property ‘‘setter’’ with the arguments
passed in and thevalueToSetas the value to assign to that property
❑ IsSettableis dynamically determined by examining theIsSettableof the referenced member
❑ IsGettableis dynamically determined by examining theIsGettableof the referenced member
❑ TypeNameOfValuereturnstypeof(PSParameterizedProperty).FullName
Sets
PSObjectis, at its most basic level, a named and dynamically typed collection of members It is very ful to be able to partition these sets of members into different subsets so that the subset may be referencedtogether There are two types of member subsets:
use-❑ PropertySet— A name to specify a number of properties
❑ MemberSet— A collection of any extended member types These are defined more fully in the
following subsections
Taken together these sets offer powerful capabilities For example, PowerShell defines a well-known
MemberSet PSStandardMembersto define how parts of the PowerShell system will interact with a
par-ticularPSObject One specific case is thePropertySet DefaultDisplayPropertySet, which is used by
formatting and output to determine at runtime which properties to display for a givenPSObject
PSPropertySet
APSPropertySetacts as an alias that points to n other properties It is used to refer to a set of properties
that have a common purpose or use These properties may then be referred to as a ‘‘set’’ by single name.You can normally use aPropertySetwhenever a list of properties is requested
The definition of aPSPropertySetis shown in Figure 3-19
❑ Constructortakes the name of the member to create and anIEnumerable<string>that statesthe names of the properties to reference whenValueis retrieved The members referred to by
referencedPropertyNamesmust be of typePSMemberTypes.PropertiesorPSMemberTypes
Trang 7class PSPropertySet
PSMemberInfo
PSPropertySet
+ Copy() : PSMemberInfo+ PSPropertySet(string, IEnumerable<string>)+ ToString() : string
«property»
+ MemberType() : PSMemberTypes+ ReferencedPropertyNames() : Collection<string>
+ TypeNameOfValue() : string+ Value() : object
Figure 3-19: Definition of a PSPropertySet
For example, you could create aPropertySetthat states the times of interest for a particular file:
PS C:\> $fileobj = get-childitem bootsect.bak
PS C:\> $fileobj | select-object Times
PS C:\>
PSMemberSet
APSMemberSetcontains other extended members of any type Importantly, thethispointer inside
thePSMemberSetrefers to the containingPSObject Therefore,ScriptProperties,ScriptMethods,
AliasProperties,PropertySet, and so forth may all reference the members in thePSObject(see
Figure 3-20)
❑ Constructortakes the name of theMemberSetto create An additional constructor takes the
name of theMemberSetto create and anIEnumerable<PSMemberInfo>that specifies the
mem-bers to add to that MemberSet
❑ Membersgets the collection of members contained in thisMemberSet
❑ Methodsgets the collection of methods (PSMemberTypes.Methods) contained in thisMemberSet
Trang 8❑ Propertiesgets the collection of properties (PSMemberTypes.Properties) contained in thisberSet.
Mem-❑ InheritMemberstells thisMemberSetto walk theTypeNamesduring a lookup of members This
means that any members of a parent type that are in aMemberSetof the same name will be
available through thisMemberSet The default isTrue
❑ Valuereturns thePSMemberSetitself An attempt tosetvalue throwsNotSupported
❑ TypeNameOfValueis the fully qualified type name ofPSMemberSet(i.e.,System.Management
«property»
+ InheritMembers() : bool + Members() : PSMemberInfoCollection<PSMemberInfo>
+ MemberType() : PSMemberTypes + Methods() : PSMemberInfoCollection<PSMethodInfo>
+ Properties() : PSMemberInfoCollection<PSPropertyInfo>
+ TypeNameOfValue() : string + Value() : object
Figure 3-20: Members in thePSObject
For example, aPSObjectwith aFileInfo BaseObjectcontains members ofMode(aScriptProperty),
LastWriteTime(aPSProperty),Length(aPSProperty), andName(aPSProperty) In the well-known
MemberSet PSStandardMembers, aPropertySetmember could be added that referred to those members
MemberSetsallow different parties to createExtendedMembersin a less conflicting way; only theSetname conflicts, its contained members do not
Member-ETS itself uses this functionality and defines a few well-knownMemberSets, as described in the section
‘‘Standard MemberSets.’’
TypeNames
TypeNamesis the list ofTypeNamesthat thisPSObjectrepresents (it is aCollection<String>) Upon
instantiation,TypeNamesis set to the derivation hierarchy of theBaseObject If there is noBaseObject,thenTypeNamesis empty
A singleTypeNameis represented by a string, enabling the script developer to define new types
dynamically Therefore,TypeNamesallows for dynamic derivation; that is, it allows a developer to statefrom whichTypeNameaPSObjectshould derive
Trang 9TypeNamesare ordered such that the least index takes greatest precedence (e.g., members defined in
TypeNames[0]will take precedence over members defined inTypeNames[1]) In other words,TypeNames
lists the types from most specific to least specific See the following section, ‘‘Lookup Algorithm,’’ to learn
how this is done
Lookup Algorithm
A lookup algorithm is used any time a developer references a member — for example, accessing the
member of a variable like$a.x(inside a script) For a code developer, this lookup algorithm is initiated
while accessing the members, properties, methods, or index properties ofPSObject
Conceptually, the basic algorithm is designed to look up the members in the following order:
1. Extended instance members:These are the members added to an object using the
add-membercmdlet
2. Extended type members:This is done by walking upTypeNamesagainst theTypeDatafile(s)
Essentially, for each element inTypeNames(starting with Length-1), it walks the list of
Type-ConfigurationEntry(starting with 0) looking for the definition of an extended member
for that type When found, it adds those members (or returns the member if looking for
a single member) and starts the lookup for the nextTypeName In this way, 0thTypeName
and 0thTypeConfigurationEntryshould win (i.e., override others later in the list)
3. Adapted members:This is done by querying the type adapter for properties and methods of
the particular name(s) desired This interface is not public at this time
Notice that we do not actually lookup against theBaseMembers This is because adapters hide the
BaseOb-jectin the default lookup When theBaseObjectis a NET class, an internal defaultDotNetadapter is
used Therefore, an adapter is always available for any given object As noted earlier, explicit access to
BaseMembersis available through a hiddenPSBaseproperty in script For a programmer, access to the
original CLR object is available through the propertyImmediateBaseObject(of thePSObject)
Naming collisions are not possible between extended instance members and extended type members — it
is an error to add an extended instance member that would collide with an extended type member
Naming collisions are currently possible between extended members and adapted members In such
a case, extended members override adapted members Proper care needs to be taken while adding
extended members through type files, through theadd-membercmdlet, or by adding directly to
aPSObject
Distance Algorithm
Distance algorithms are used to determine which method to call when more than one method is possible
(for example, when overloads are present) This is done by determining the distance between every
argument and its corresponding parameter for each overload The distance between an argument and
a parameter is determined by a table with a heuristic approximation of the risk involved in the type
conversion between the two types The types that are understood (have an entry in this table) are as
follows:char,int16,int32,int64,UInt16,UInt32,UInt64,float,double,decimal,bool,string,
char[],regex,XmlDocument,object []
Trang 10A script developer may modify the results of the distance algorithm by ‘‘cast’’ing the arguments to matchthe parameters of a certain overload.
This table is currently hard-coded, so it doesn’t take into account the additional converters or constructors
that might be specified by a developer.
PSObject Intrinsic Members and MemberSets
To facilitate developer access and control,PSObjectsupports five intrinsic members:PSExtended,
PSAdapted,PSBase,PSObject, andPSTypeNames
In order to allow developers to override the lookup algorithm and directly access each type of member,
PSObjectintrinsically supports threeMemberSets:
❑ PSExtended: ThisMemberSetallows access to all extended members, and only extended
members No adapted members are present For example,$a.PSExtended.xwill get the
ExtendedMember x It will not make any access to the adapter if there is noExtendedMemberby
that name (in this case,x)
❑ PSAdapted: ThisMemberSetallows access to all members made available through the adapter
indicated by theBaseObject
❑ PSBase: ThisMemberSetallows direct access to all public members on theBaseObject No access
is made to anExtendedMemberor anAdaptedMember
PSObjectallows script developers to directly access it (the meta-object) as needed It does this by
pro-viding aMemberSetnamedPSObject Therefore,$a.PSObject.Membersreferences theMemberspropertyavailable onPSObjectitself, returning aPSMemberInfoCollection
As noted, theTypeNameslist is the mechanism the system uses to determine the ‘‘type’’ of a
PSObject As shown in the section ‘‘Lookup Algorithm,’’ theTypeNameslist enables the developer
to dynamically define derivation.PSObjectsupplies an intrinsicNotePropertynamedPSTypeNames
that references this list Therefore,$a.PSTypeNamesshows theTypeNameslist for$a
Errors and Exceptions
Errors can occur in the ETS at two points: during initialization (loading) of type data (see
‘‘Initializa-tion Errors’’), and when accessing a member of aPSObjector using one of the utility classes such as
LanguagePrimitivies (See the following section, ‘‘Runtime Errors.’’)
ETS does not swallow any exceptions
Runtime Errors
With one exception noted below, all the exceptions thrown from the ETS during runtime are,
or derive from,ExtendedTypeSystemException, which derives fromRuntimeException Therefore,
they may be trapped by advanced script developers using theTrapstatement in the PowerShell
language
Trang 11All exceptions that occur when getting the value of aPSMemberare of the typeGetValueException When
the ETS itself recognizes the error, aGetValueExceptionis thrown When the underlyingget, such as
aCodeProperty, throws an exception, aGetValueInvocationExceptionis thrown with the getter’s
exception as the inner exception
All exceptions that occur during a set of the value of aPSMemberTypes.Propertyare of the type
SetVal-ueException When the ETS itself recognizes the error, aSetValueExceptionis thrown If the underlying
get, such as aCodeProperty, throws an exception, then aSetValueInvocationExceptionis thrown with
the getter’s exception as the inner exception
All exceptions that occur during the invocation of aPSMemberTypes.Methodare of type
MethodExcep-tion When the ETS itself recognizes the error, aMethodExceptionis thrown When the underlying
CodeMethodthrows an exception, aMethodInvocationExceptionis thrown with theCodeMethod’s
excep-tion as the inner excepexcep-tion
When an invalid cast is attempted, aPSInvalidCastExceptionis thrown Because this derives from
InvalidCastException, it cannot be directly trapped from script This means that the entity attempting
the cast would need to wrapPSInvalidCastExceptionin aPSRuntimeExceptionin order for this to be
trappable by script developers
If an attempt is made to set a value ofPSPropertySet,PSMemberSet,PSMethodInfo, or a member of a
ReadOnlyPSMemberInfoCollection, aNotSupportedExceptionis thrown
All other exceptions areExtendedTypeSystemExceptioninstead of more specific derived exceptions
Initialization Errors
Errors in loading atypexmlfile should work like other PowerShell errors If processing can continue,
then it is a nonfatal error and it would callWriteDebug(because there’s noErrorpipe at this time) If
a terminating error is found such that the rest of the file cannot continue, then the rest of the file is not
processed (but does not throw a terminating exception) Note that there are no terminating errors at
this time
Information includes the following:
❑ Filename
❑ Line number
❑ Type in which the error occurred
❑ Member in which the error occurred
❑ Specific cause of the error
For example, adding a duplicate membercountto theSystem.Objectarray would provide the following
error:
DEBUG: Error loading Types.PSxml:
c:\temp\monad\types.PSxml(8) : Error in type "System.Object[]":
Member "Count" is already present
Trang 12Type Conversion
Type converters are used any time an attempt is made to convert an object of one type to another type
(such asstringtoint) For example, theParameterBindingalgorithm performs type conversion whentrying to bind incoming objects to a particular parameter and during casts in the PowerShell scripting
language
Attempts to convert one object to another type are separated into two different buckets:
❑ Standard PowerShell Language conversions:These are checked first and cannot be overridden
❑ Custom conversions
Both are discussed in detail in the following sections
Standard PS Language Conversion
Standard PS Language conversions follow the order shown in the following table when converting a
value from one type to another type (note thatvalueToConvertis used to represent the object to convert)
From Type To Type Returns
null String String.Empty
Anything void AutomationNull.Value
Anything String Calls the ToString mechanism (see the section
‘‘ToString Mechanism’’)Anything Boolean LanguagePrimitives.IsTrue(valueToConvert)
Anything PSObject PSObject.AsPSObject(valueToConvert)
Anything XMLDocument Converts valueToConvert to String, and then calls the
XMLDocument constructorAnything Nullable<T> Converts to Nullable<T>(valueToConvert is first converted
to type T If conversion succeeds, then the converted value
is used to convert to Nullable<T>.)
Array Array Tries to convert each array element
Trang 13From Type To Type Returns
Singleton Array array[0] = valueToConvert converted to the element type of
the arrayIDictionary Hashtable Hashtable(valueToConvert)
String Char[] valueToConvert.ToCharArray()
String RegEx RegEx(valueToConvert)
String Type Uses the valueToConvert to search in the internal
representation of RunSpaceConfiguration.AssembliesString Numeric If valueToConvert is ‘‘’’, then it returns 0 of the resultType
Otherwise, the culture ‘‘culture invariant’’ is used to produce
a numeric value
Integer System.Enum Converts the integer to the enumeration if the integer is
defined in that enumeration If the integer is not defined inthat enumeration, then it throws an PSInvalidCastException
Custom Converters
If none of the preceding Standard PowerShell Language conversions apply, then custom converters
are checked
If one of the following custom conversion operations throws an exception (i.e., the converter is found
but it fails the conversion), then no further attempt to convert the object will be made and the original
exception is wrapped in aPSInvalidCastException, which will then be thrown
Custom converters are executed in the following order:
TypeConverter
This is a CLR defined type that can be assigned to a particular type using theTypeConverterAttributeor
the<TypeConverter>tag inTypeData(see the ‘‘Type Configuration’’ section) If thevalueToConverthas
aTypeConverterthat can convert toresultType, then it is called If theresultTypehas aTypeConverter
that can convert fromvalueToConvert, then it is called
The CLRTypeConverterdoes not allow a single type converter to work for n different classes.
Parse
If thevalueToConvertis a string and theresultTypehas aParsemethod, then it is called
Parseis a well-known method name in the CLR world.
❑ Constructors:If theresultTypehas a constructor that takes a single parameter of type
value-ToConvert.GetType(), then this is called
Trang 14❑ Implicit cast operator:IfvalueToConverthas an implicit cast operator that converts to
resultType, then it is called IfresultTypehas an implicit cast operator that converts from
valueToConvert, then it is called
❑ Explicit cast operator:IfvalueToConverthas an explicit cast operator that converts to
resultType, then it is called IfresultTypehas an explicit cast operator that converts from
valueToConvert, then it is called
❑ IConvertible: System.Convert.ChangeType is then called
PSTypeConverter
APSTypeConvertercan be assigned to a particular type using theTypeConverterAttributeor the
<TypeConverter>tag in theTypeDatafile (see the ‘‘Type Configuration’’ section for more details) If the
valueToConverthas aPSTypeConverterthat can convert toresultType, then thisPSTypeConverteriscalled If theresultTypehas aPSTypeConverterthat can convert fromvalueToConvert, then it is called
PSTypeConverterallows a single type converter to work for n different classes For example, anenum
type converter can convert a string to anyenum(there doesn’t need to be a separate type to convert
Figure 3-21:PSTypeConverterclass
In order to usePSTypeConverter, attribute the class withTypeConverterAttribute, passing it your typeconverter derived fromPSTypeConverter
Specific Implementations of PSTypeConverter
Windows PowerShell ships with a customPSTypeConvertercalledConvertThroughString, which
specifies that a particular destination type will always usevalueToConvert.ToString()before being
converted using the standard string conversions to the destination type:
public class ConvertThroughString : PSTypeConverter
{
public override bool CanConvertFrom(object sourceValue, Type destinationType);
Trang 15public override object ConvertFrom(object sourceValue, Type Type, IFormatProvider formatProvider, bool ignoreCase); // for string conversions
destination-public override bool CanConvertTo(object sourceValue, Type destinationType);
public override object ConvertTo(object sourceValue, Type destinationType,
IFor-matProvider forIFor-matProvider, bool ignoreCase);
}
ToString Mechanism
PSObjectimplements a version ofToString that is designed to allow customization ofToStringand
provide the most useful implementation of it It does this by following the logic shown here:
❑ If there is aPSCodeMethodnamedToString, then it is called and its value returned
❑ If theBaseObjectisIEnumerable, then theOutput-Field-Separator($OFS) separated list of the
ToStringof each element is returned — theToStringof the element might clearly be
overridden using the other mechanisms If the enumeration throws an exception, then the
BaseObject.ToStringis attempted
❑ If theBaseObjectisPSNullBaseObject, then the members of typePSMemberTypes.Properties
are returned in hash table syntax
❑ Otherwise, theBaseObject.ToStringis called and its value returned IfBaseObject.ToString
throws an exception, then this original exception is wrapped in an
ExtendedTypeSystemExcep-tion, which is then thrown
Type Configuration (TypeData)
In the preceding examples, only instance members are used to keep them simple However, all extended
members may also be defined against aTypeNamein a type configuration XML specification Because
XML is case sensitive, the nodes ofTypeDataare also case sensitive However, the contents of those
nodes are not case sensitive
The following example defines the schema of a type configuration file For the sake of brevity, I used the
following logic to define the schema:
❑ Indentation represents containment For example, the element<Types>contains the
<Type> element
❑ Symbols in square brackets (e.g.,[0 X]) represent cardinality
❑ [0 Many]indicates that a particular element can occur 0 to many times
Trang 17<ScriptMethod> [0 Many]
<CodeMethod> [0 Many]
<PropertySet> [0 Many]
<MemberSet> [0 Many]
As per the preceding rules, there can be only one<Types>element in a type configuration file However,
there can be many<Type>elements inside a<Types>element
If<InheritMembers>element is present, then it must have aninnerText ThatinnerTextmust be either
TrueorFalse(case-insensitive) By default,MemberSetsinherit members (refer to the ‘‘PSMemberSet’’
section for more details)
If there is a definition conflict between different type configuration entries (or files), then the first one
processed without errors wins
If a schema check fails (e.g., a child element is of the wrong cardinality), then that entry is not processed
For example, if a<Type>element has two<Name>child elements, then that<Type>entry fails to be
loaded into Windows PowerShell’s type table
Well-Known Members
In order for the PowerShell system itself to understand how to best operate against a particular
PSOb-ject, a set of well-known members is provided For example, there is a particular member that defines what
properties to display by default, or what properties to use for sorting These members should be
associ-ated with eachPSObject(either by addingInstanceMembersorTypeMembers) that want to participate in
these activities
Script Access
Scripts are able to access all extended members, adapted members, and base members, as well as the
PSObjectitself (the meta-object that contains all those) By default, script access has been optimized
using the lookup algorithm described earlier However, using the specialMemberSetsdescribed above,
script developers have complete access to all the different capabilities and abstractions of aPSObject
This approach enables both simple day-to-day usage as well as the creation of powerful scripts
Summar y
The Extended Type System (ETS) is one of the core elements of the Windows PowerShell Engine and it
forms the basis of all object access and manipulation in Windows PowerShell This chapter took a close
look at the ETS, including the following topics:
❑ ThePSObjectand its various members
❑ Construction of thePSObject
❑ Different member types of thePSObject
❑ Details about each of the extended members that can be created and added to thePSObject