Testing Policy-Instances

Tests, if at least one Policy-Instance exists for the given target or for the specified Software-Package. When supplying both parameters, you can check if a Policy-Instance was created for the Software-Package on the target. Returns true if the test succeeds and false if it fails.


Examples:


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


The following command simply checks, if the Computer "WIN10-01" has any Software Assignments (or to be more precise: if there is a Policy-Instance for any Package):


Test-EmdbPolicyInstance "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\Production\Workstations\WIN10-01"


Similarly, the commands below test, if the Software Package "KeePass 2.35" is not only assigned to a target but if Policy-Instances exist:


$MyPackage = Get-EmdbSoftwarePackage "emdb:\rootDSE\Global Software Library\Application Library\Open Source Software\KeePass\KeePass 2.35"

Test-EmdbPolicyInstance -Item $MyPackage


Last but not least we want to check, if any version of Google Chrome (we assume there are several Packages for different Google Chrome versions and that they can all be retrieved in one step and are stored in the $MyPackages variable) is assigned to Computer "WIN7-CLT08" and if there is a Policy-Instance:


$MyPackages = Get-EmdbSoftwarePackage "Google Chrome *" -Recurse

$MyTarget = Get-EmdbComputer "WIN7-CLT08" -Recurse

Test-EmdbPolicyInstance -Item $MyTarget -RelatedItem $MyPackages -Any