Script Repository

Add / remove object from group upon adding / removing it from another group

February 24, 2021

The script adds or removes objects from a specific group upon adding or removing them from another group. To use the script, create a business rule triggering After adding or removing a member from a group. An object will be added to or removed from the target group when added or removed from one of the groups in the Activity Scope of the rule.

In the following example, objects will be added or removed from the Resources group after adding or removing them from one of the groups located in the Resources OU.

Business Rule configuration


  • $targetGroupDN - Specifies the Distinguished Name (DN) of the group to add or remove members from.
Edit Remove
$targetGroupDN = "CN=Resources,OU=Groups,DC=example,DC=com" # TODO: modify me

$group = $Context.BindToObjectEx("Adaxes://$targetGroupDN", $True)
if (($Context.Action.IsOperationOfType($Context.TargetObject, "remove group members")) -and
elseif (($Context.Action.IsOperationOfType($Context.TargetObject, "add group members")) -and (-not ($group.IsMember("Adaxes://%member%"))))

Comments ( 2 )
Mar 21, 2019
Had a problem with the script that when I removed one member which was not member of the target group, it was added to the group.
Change the line with elseif to avoid this:
elseif (($Context.Action.IsOperationOfType($Context.TargetObject, "add group members")) -and (-not ($group.IsMember("Adaxes://%member%"))))
Mar 22, 2019


Thank you for pointing out the issue. We have updated the script accordingly.

Leave a comment

Related Scripts