Setting Schema Extension values

Setting the value of properties defined via schema extensions is done very similar like reading those values.


There are two types of schema extensions in DSM 2014.1 that need to be considered separately: the first one are properties where the values are set by the managed system (the client) and that are called "State-Info". The second one are properties which values can be set in the DSMC and that type is called "Management-Info".


With the release of Service Pack 1 for DSM 2014.1, two important changes were introduced:

  • the former computer-property "Initial MAC-Address" was moved to the property-group "Basic-Inventory". Furthermore this property was changed from type "Management-Info" to type "State-Info"
  • Values of schema extensions of type "State-Info" can now be changed via the console - and thus also via the PowerShell Extensions


Setting the value of properties is done via the SetPropertyValue()-method. It doesn't matter in this case, if the value of a standard-property of type "Management-Info", the value of a user-defined property of this type (that is a schema-extension) or the value of a schema extension of type "State-Info" needs to be set. After calling the SetPropertyValue()-method, the object changed must be saved using the Update()-method.


Examples:


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


In the following example, the value of the property "Description", which is of type "Management-Info" and is a standard-property, is set for computer "XP01":


$MyComputer = Get-EmdbComputer "XP01" –Recurse

$MyComputer.SetPropertyValue("Description", "This is the new description")

$MyComputer.Update()


As described above, with the release of DSM 2014.1 Service Pack 1, the property "Initial MAC-Address" is now of type "State-Info". Nevertheless, this property's value - as the value of the property "SMBIOS-GUID" - can be set via the Administration Webservice and thus via PowerShell. This is important and necessary in the case of a hardware-change, where a new motherboard is inserted into a system, that is already managed via DSM. The following example shows how to deal with this:


$MyComputer.SetPropertyValue("InitialMACAddress", "001122334455")

$MyComputer.SetPropertyValue("SmBiosGuid", "{00000000-1111-2222-3333-4444444444}")

$MyComputer.Update()


Note: For properties of type "State-Info", only the values of the two standard-properties "Initial MAC-Address" and "SMBIOS-GUID" and the values of user-defined properties can be changed. The values of all other out-of-the-box properties of type "State-Info" are read-only.


Let's assume, you have defined a schema extension for computer-objects of type "Management-Info" called "Inventory-ID". The following code-snippet changes the value of this property for the current computer-object to "PC0815-001":


$MyComputer.SetPropertyValue("Inventory-ID", "PC0815-001")

$MyComputer.Update()