Removing Context-Menu-Groups

Userdefined Context-Menu-Groups are deleted using the cmdlet Remove-EmdbUITaskGroup or by invoking the object's Delete()-method.


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

The following example deletes the userdefined Context-Menu-Group "Computermanagement" by using the Remove-EmdbUITaskGroup cmdlet:

Remove-EmdbUITaskGroup "Computermanagement"

Alternatively, the following code snippet first retrieves the object associated with the userdefined Context-Menu-Group "Computermanagement" and deletes it subsequently by using the object's Delete()-method:

$MyUITaskGroup = Get-EmdbUITaskGroup "Custom_Computermanagement"


In order to delete all userdefined Context-Menu-Groups, the code shown below can be used, for example:

Get-EmdbUITaskGroup | Where-Object {$_.IsSystem -eq $false} | ForEach-Object {$_.Delete()}

Note: As long a a Context-Menu-Group contains userdefined tasks, it cannot be deleted. You have to delete all associated Context-Menu-Entries first, as described here.

Note: Note that Context-Menu-Group 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 Context-Menu-Group 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.