0 votes

I have tried it using the Custom Commands Action "Add the user to a group", which only allows me to add the user to one group at a time, and can't use the multiple DNs that the object picker parameter provides.

Next I tried a powershell script:

$groupsParam = %param-gruppen% # TODO: modify me
$groupsParamSeparator = ";" # TODO: modify me

$groups = $Context.GetParameterValue($groupsParam)
foreach ($dn in $groups.Split($groupsParamSeparator))
{
    $groups.Add($Context.TargetObject.AdsPath)
}

But I can't get it to work. Could you assist me in finding the best way to do this?

by (280 points)

1 Answer

0 votes
by (284k points)
selected by
Best answer

Hello Dominik,

You can use the below script in a custom command configured for the User object type. In the script:

  • $groupsParam – Specifies the name of the parameter that will be used to select groups. The name must include the param- prefix
  • $groupsParamSeparator – Specifies the separator enter for multiple values in the parameter settings. Make sure not to use English characters or comma as they are always present in object DNs and will not work as separator. image.png
  • $pipelined – If set to false, adding to groups will be performed directly in AD and Adaxes workflows will not trigger. Also, there will be no log records for group updates in Adaxes.
$groupsParam = "param-gruppen" # TODO: modify me
$groupsParamSeparator = ";" # TODO: modify me
$pipelined = $True # TODO: modify me

# Get parameter value
$groupDNs = $Context.GetParameterValue($groupsParam)

foreach ($groupDN in $groupDNs.Split($groupsParamSeparator))
{
    # Bind to the group
    $group = $Context.BindToObjectByDNEx($groupDN, $pipelined)

    # Add target user to group
    $group.Add($Context.TargetObject.AdsPath)
}
0

This has worked perfectly, thanks so much for responding so fast!

Related questions

0 votes
1 answer

Occationally Service Desk staff need to clear a DNS record when a desktop has been reimaged but is keeping the same name as loses the ability to manage its original DNS ... running in ADAXES. Can I just install the applet on the ADAXES server using powershell?

asked Jan 17, 2023 by stevehalvorson (110 points)
0 votes
1 answer

Here is my issue, When I use this code: $DNs = %param-GroupsInRole% $Groups = $DNs -split "|" %Param-GroupsInRole% can have multiple groups. When setting up the parameter I am ... I just need to be able to do a foreach with the groups picked by the initiator.

asked Mar 23, 2023 by mightycabal (1.0k points)
0 votes
1 answer

Hi all, How can I add a user directly to an Entra ID group? I understand it might be possible via CLI e.g. Add-AzureADGroupMember - But is there a built-in GUI method via Business Rules? Thanks, David

asked Oct 2 by dshortall (60 points)
0 votes
1 answer

I would like to add a parameter for country to a custom command. Since the country has to be entered correctly in order for Active Directory to accept it, I would like to ... ? I didn't find it in the documentation and the sample scripts didn't use parameters.

asked Jun 4, 2020 by mark.it.admin (2.3k points)
0 votes
1 answer

Hi there, I've created a Delete User feature in the Web Interface Configurator. I am trying to restrict object selection via a User Criteria. Need to exclude Service ... won't appear when selecting target user for the 'Delete User' feature. Thanks, David

asked Sep 19 by dshortall (60 points)
3,504 questions
3,196 answers
8,148 comments
547,431 users