Testing Policies

Tests, if a Policy exists for the given target or for the given Software Package. Alternatively both item can be specified, resulting in a check, if the Package is assigned to 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.


It is a common best practise to assign Software Packages to Groups only and to use the ODS tree with its Domain and Organizational Unit objects as an hierarchical structure only. The following first example therefore tests, if any Software Assignments exist on Organizational Units:


$MyOUList = Get-EmdbOrganizationalUnit -Path emdb: -Name * -Recurse

Test-EmdbPolicy -Item $MyOUList -Any


Note: When specifying the Any switch, the cmdlet returns true if at least one of the tests is successful.


The second example checks, if there are any Policies for the Software Package "Notepad++ 7.3" which means we test if it is assigned anywhere:


Test-EmdbPolicy "emdb:\rootDSE\Global Software Library\Application Library\Open Source Software\Notepad++\Notepad++ 7.3"


In the last example we want to know, if the Package "7-Zip (x64) 16.04" is assigned to the Group "Windows 10 (x64) Baseline":


$MyPackage = Get-EmdbSoftwarePackage "7-Zip (x64) 16.04" -Recurse

$MyTarget = Get-EmdbGroup "Windows 10 (x64) Baseline" -Recurse

Test-EmdbPolicy -Item $MyPackage -RelatedItem $MyTarget