Removing Roles

This chapter describes deleting Role-objects.


Examples:


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


To delete user-created or DSM 2014.1 built-in Role-objects (note the hint below), the Remove-EmdbRole Cmdlet is used. The Role "Testing Manager", that was created beforehand, can be deleted using the following commands:


Remove-EmdbRole "Testing Manager"


Alternatively, the Delete()-method of the corresponding object can be used:


$MyRole = Get-EmdbRole "Testing Manager"

$MyRole.Delete()


It it also possible to use the Remove-Item Cmdlet. If you are using that option, you have to take into account, that Role-objects are a member of the container rootCatalog and are not located in the usually used container rootDSE:


Remove-Item "emdb:\rootCatalog\Testing Manager"


Note: It's not possible to delete System-Roles. The roles "Read", "Supervisor", "Manage Monitor Definitions" and "View Management Reports" cannot be deleted.


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.


Starting with PSX 3.1 there was a new option implemented when deleting Role objects. When specifying the SingleItemExpected-switch it is expected, that none or exactly one object is affected. If the command would delete more than one object, an error is raised that can be caught and handled in scripts.