Script repository

Add target account to groups selected in a parameter

Updated on: Jan 18, 2026, Views: 2927

Group membership

The script adds the target account to the groups selected in a custom command parameter. To execute the script, create a custom command configured for the required object type.

Parameters

  • $groupsParameterName - the name of the Directory object picker parameter used to select groups. The parameter name must be specified with the param- prefix.
  • $separator – a separator (e.g. semicolon) for groups in the parameter.
  • $pipelined - set to $true to add the target object to the groups through Adaxes pipeline to create log records, apply business rules, security roles, etc. Set to $false to perform group membership update directly in AD (Adaxes functionality will not be applied).
$groupsParameterName = "param-Groups" # TODO: modify me
$separator = ";" # TODO: modify me
$pipelined = $True # TODO: modify me

# Get parameter value.
$groupsToAdd = $Context.GetParameterValue($groupsParameterName)

# Update the group membership.
foreach ($groupDn in $groupsToAdd.Split($separator))
{
    $group = $Context.BindToObjectByDNEx($groupDn, $pipelined)
    if(-not $group.IsMember($Context.TargetObject.AdsPath))
    {
        $group.Add($Context.TargetObject.AdsPath)
    }
}

Comments 0

You must be signed in to comment.

    Got questions?

    Support Questions & Answers

    We use cookies to improve your experience.
    By your continued use of this site you accept such use.
    For more details please see our privacy policy and cookies policy.