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.

Script repository

Add target account to groups selected in a parameter

July 23, 2025 Views: 8

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 - Specifies the name of the Directory object picker parameter used to select groups. The parameter name must be specified with the param- prefix.
  • $separator – Specifies 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).
Edit Remove
PowerShell
$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
Leave a comment
Loading...

Got questions?

Support Questions & Answers