Script repository
The script adds a user to the groups specified in a DN syntax property. To execute the script, create a business rule, custom command or scheduled task configured for the User object type.
$propertyName = "seeAlso" # TODO: modify me
try
{
# Get group DNs.
$groupDNs = $Context.TargetObject.GetEx($propertyName)
}
catch
{
return
}
# Add user to groups.
foreach ($dn in $groupDNs)
{
try
{
$group = $Context.BindToObjectByDNEx($dn, $True)
$group.Add($Context.TargetObject.AdsPath)
}
catch
{
$Context.LogMessage("An error occurred while adding to group '$dn':" + $_.Exception.Message, "Warning")
}
}
Comments 0
You must be signed in to comment.