Hello,
It has to be an array containing distinguished names (DNs) of the objects. Also, your script misses the line for loading the assembly. Finally, it should look like the following:
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")
# Bind to the custom command
$commandDN = "<distinguished name of the custom command>"
$command = $admService.OpenObject("Adaxes://$commandDN", $NULL, $NULL, 0)
# define parameter values
$groupName = "GroupName"
$owners = @("Owner1DistinguishedName", "Owner2DistinguishedName", "Owner3DistinguishedName")
$members = @("Member1DistinguishedName", "Member2DistinguishedName", "Member3DistinguishedName")
# Specify the arguments for command execution
$commandArguments = $command.CreateArguments()
$commandArguments.SetParameterValue("param-groupName", $groupName) # edit box parameter
$commandArguments.SetParameterValue("param-owners", $owners) # AD object picker parameter
$commandArguments.SetParameterValue("param-members", $members) # AD object picker parameter
# Run the custom command
$obj = $admService.OpenObject("Adaxes://<distinguished name of OU>", $NULL, $NULL, 0)
$obj.ExecuteCustomCommand($command.CommandID, $commandArguments)
If you get error messages using this approach, it means that there is something incorrect about working with the parameters in your custom command itself, not in the script executing the command. For example, if you need to add the target user to multiple groups selected in the parameter, the script in the custom command will look like below.
$separator = ";" # TODO: modify me
# Get parameter value
$parameterValue = $Context.GetParameterValue("param-owners")
# Add user to groups
foreach ($dn in $parameterValue.Split($separator))
{
$group = $Context.BindToObjectByDN($dn)
$group.Add($Context.TargetObject.AdsPath)
}
In the script, the $separator variable specifies the character used to separate object DNs in the parameter. It must match that specified in the parameter settings.