Testing Roles
Testing Roles
The Test-EmdbRole cmdlet can be used for either testing, if a specific Role exists as well as for testing, if a User or Group are Role-members in a given context. The result is always true, it the test succeeds or false, if it fails.
Examples:
Hint: The execution of these examples requires a connected PowerShell drive. |
The following example tests, if the user-defined Role"Junior-Packager" exists:
Test-EmdbRole "Junior-Packager" |
Using the code-snippet below, you can test, if the User "Albert Tross" is member of the Role "Junior-Packager" in the context of the Organizational-Unit "Chicago":
$MyRole = Get-EmdbRole "Junior-Packager" $MyUser = Get-EmdbUser "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago\Production\Users\Albert Tross" $MyOU = Get-EmdbOrganizationalUnit "emdb:\rootDSE\Managed Users & Computers\solys.local\Chicago" Test-EmdbRole -Role $MyRole -Grantee $MyUser -OnObject $MyOU |
Note: Note that Role-objects are not part of the context rootDSE and therefore they can be referenced without a full qualified path resp. an absolute path. |