Methods and properties of objects
Methods and properties of objects
The PowerShell Extensions for Ivanti DSM follow - as the PowerShell in general - an object oriented paradigm. That is, every object (incl. its properties) managed by the DSMDB is available in the PowerShell console or script. You can request the values of these properties and set most of them as well. Furthermore methods are associated with the objects. Calling the methods triggers actions that manipulate the object itself or other associated objects.
For some common and often used methods cmdlets are implemented. The cmdlets enable you get the input objects for actions from PowerShell pipelines and write objects back to a pipeline. The cmdlets cover only a small subset of the available functionality. All other functionality is implemented as methods of objects.
If you want to delete a computer from the DSMDB for instance, you will notice that there is no cmdlet like "Remove-EmdbComputer". Nevertheless, nearly every object supports a method named Delete(), so a computer is deleted from the DSMDB by calling this method on the computer object:
$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP01" $MyComputer.Delete() |
Properties of objects can be easily accessed, as far as they are not declared as "volatile" by the DSMDB:
$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP02" Write-Host The type of this computer is $MyComputer.ComputerType |
The value of a writable property can be manipulated if you assign a valid value to the property and subsequently call the method Update()on the object. In the next example, a computer is classified as a virtual machine by assigning the value "Virtual Machine" to the property "ComputerType":
$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP02" $MyComputer.ComputerType = "Virtual Machine" $MyComputer.Update() |
Hint: Often you do not need to know the exact internal range of values to provide a valid value for a certain property. The localized display name of the value of the property as shown by the DSMC will do. |
To determine which methods and properties are provided by a given object, you can use the usual PowerShell mechanisms. Just pipe the object in question to the cmdlet Get-Member. In the example below all methods and properties associated with an object of type "Computer" are printed:
$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP02" $MyComputer | Get-Member |
Computer objects come with a lot of methods and properties that are useful in your own scripts. You can explore all available object types in the same way.
If you are interested in the values of all properties of an object you can print out them using the following command:
$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\ITService\Workstations\XP02" $MyComputer | Format-List * |
The command prints all property values of the given computer formatted as a list.