Retrieving Variable-values
Retrieving Variable-values
When retrieving the values of Variables, you have always to specify the target-object for which the Variable-values should be resolved. Resolving is possible via the Get-EmdbVariable cmdlet which must be used in conjunction with the Target parameter. Another possibility is the usage of the ResolveVariables()-method of objects.
Examples:
Hint: The execution of these examples requires a connected PowerShell drive. |
Using the Get-EmdbVariable cmdlet, all Variables having a value a retrieved for computer XP01 in the following example. The result returned is a collection of objects having a Value property:
$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP01" Get-EmdbVariable -Target $MyComputer |
If you just want to resolve one Variable, its name can be specified:
Get-EmdbVariable "InternalID" -Target $MyComputer |
In order to store the explicit value of a Variable for a specified target in a PowerShell-variable, the following code-snippet can be used:
$MyValue = (Get-EmdbVariable "InternalID" -Target $MyComputer).Value |
As described above, as an alternative the ResolveVariables()-method can be used, leading to the same result as in the first example:
$MyComputer.ResolveVariables() |