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).
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)
}
}