Retrieving associated items

With version 4.0 the new cmdlet Add-EmdbRelatedItem was introduced to optimize the performance when retrieving associated items via PSC from your DSM environment. The most obvious example are the assigned Software and the Target of Policy-Instances.


Examples:


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


In order to observe the effect this cmdlet has, a comparison between the "old-style" (pre PSX 4.0) and the "new-style" (with using Add-EmdbRelatedItem) is a good idea.


In the following example, first the names of all assigned Software-Packages, the names of all Target-Objects and the Compliance-state of all Policy-Instances are retrieved the "classical way". The PowerShell code could for example look like this:


$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\Production\Workstations\WIN10-01"

$MyPolicyInstances = Get-EmdbPolicyInstance $MyComputer

$MyPolicyInstances | Format-Table AssignedObjectName, TargetObjectName, ComplianceState


If you execute this example in your environment for a Computer that has a lot of Policy-Instances, you will notice how the individual data rows are retrieved and displayed one by one.


A more optimized retrieval by using the new cmdlet is carried out in the following way:


$MyComputer = Get-EmdbComputer "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\Production\Workstations\WIN10-01"

$MyPolicyInstances = Get-EmdbPolicyInstance $MyComputer

$MyPolicyInstances | Add-EmdbRelatedItem -PassThru | Format-Table AssignedObjectName, TargetObjectName, ComplianceState


Note: As long as this variable is used, you have to retrieve the assciated objects only once. They are saved to an internal cache and are available for further use.