Setting Variable-values

Variable-values can be set on different levels of the hierarchy and are then inherited by subordinated objects. Generally speaking, the "closer" a Variable-value is set to a leaf-object, as a Computer for example, the higher this assignment's priority. Further details of inheritance and priority can be found in the DSM online-help.


In order to assign a value to a Variable, the Set-EmdbVariable cmdlet is used. When using this cmdlet, besides the Variable's name, the target object and the value to be set, have to be specified. Alternatively the SetVariable()-method of objects can be used.


Examples:


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


In the following example, the value of the Variable "InternalID" is set for the object "Managed Users & Computers" to "xxx-yyyy":


$MyTarget = Get-EmdbDomain "emdb:\rootDSE\Managed Users & Computers"

Set-EmdbVariable "InternalID" -Target $MyTarget -Value "xxx-yyyy"


Since typically all Computer-objects in production are organized below this Domain, the value is passed down to all subordinated objects. In order to override the inherited value for Computer XP01, it can be set using the following code:


$MyTarget = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP01"

Set-EmdbVariable "InternalID" -Target $MyTarget -Value "001-0815"


The same goal can be achieved using the above mentioned SetVariable()-method. This method is called using two arguments: a Variable-object and the value, the variable will be assigned:


$MyTarget = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP01"

$MyVariable = Get-EmdbVariable "InternalID"

$MyTarget.SetVariable($MyVariable, "001-0815")


WARNING: When you are specifying the value of Variables of type "EncryptedString" via the PowerShell Extensions, the password is transmitted unencrypted to the BLS and saved unencrypted in the database. We urgently request you therefore, the set the value of such Variables manually in the DMSC.