Retrieving Schema Extension values

This chapter describes how you can access values of schema extensions. As schema extensions are "normal" - just userdefined - properties of an object-type, the method described below can be used for both, accessing the values of schema extensions as well as accessing properties of the standard-schema.


The method used for achieving this goal is the GetPropertyValue()-method of an object. This method reads the value of object-properties, regardless if these properties are used-defined or if they are standard-properties of the object in question.


Examples:


Hint: The execution of these examples requires a connected PowerShell drive.


In order to retrieve the value of the standard-property "InitialMACAddress" of computer "XP01", the following code-snippet can be used:


$MyComputer = Get-EmdbComputer "XP01" –Recurse

$MyComputer.GetPropertyValue("InitialMACAddress")


As properties are organized in property-groups, the name of the property-group can optionally be specified, which leads to better readable script-code. The internal name of schema extensions has to be - as described here - globally unique, and so adding the property-group name is optional. The following commands therefore lead to same result as the example above:


$MyComputer = Get-EmdbComputer "XP01" –Recurse

$MyComputer.GetPropertyValue("BasicInventory.InitialMACAddress")


Assuming you have defined a schema-extension "InventoryID" for computer-objects, the following code-snippet retrieves the value of this property for the XP01 computer:


$MyComputer.GetPropertyValue("InventoryID")


As always in the object-oriented world, the value of an object's property again is an object in the DSM 2014.1 object mode. The method used above for retrieving property values, however doesn't return an object. This is appropriate for most situations, but if you really need to access the object, you can use the following syntax: <object>.PropertyGroups.<Name of the property-group>.<name of the property>. Example:


$MyComputer = Get-EmdbComputer "XP01" –Recurse

$MyComputer.PropertyGroups.BasicInventory.InitialMACAddress