0 votes

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 use a drop down to ensure it is all formatted and spelled correctly. There are 200+ countries to fill out so if I can do it with a script it will be a lot easier. Is there a way to populate the drop down list using the sdk? I didn't find it in the documentation and the sample scripts didn't use parameters.

by (2.1k points)

Hello Mark,

Yes, it is possible. For us to provide you with the script. Please, specify from where it should take the list of countries. Should the list be predefined in the script itself?


Awesome. I got a list from Microsoft Windows.

$country = [CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures) | ForEach-Object {(New-Object System.Globalization.RegionInfo $_.Name).EnglishName} | Select-Object -Unique | Sort-Object

Hello Mark,

Could you, please, also specify whether the Custom Command already has parameters or the new parameter will be the only one?


It has parameters already. This will be added to it.

1 Answer

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

Hello Mark,

Thank you for specifying. Below is the script that will do the trick. Execute the script in Windows PowerShell on the computer where Adaxes service is installed. When prompted, enter the credentials of the Adaxes service account (specified during Adaxes installation). In the script:

  • $parameterName - Specifies the name of the parameter that will be created. Make sure it does not match a name of any existing parameters in the Custom Command.
  • $commandDN - Specifies the distinguished name (DN) of the Custom Command to which the parameter will be added. For information on how to get the DN, have a look at the following SDK article: https://adaxes.com/sdk/HowDoI.GetDnOfObject.

# Connect to the Adaxes service
$admNS = New-Object "Softerra.Adaxes.Adsi.AdmNamespace"
$admService = $admNS.GetServiceDirectly("localhost")

$parameterName = "Country" # TODO: modify me
$commandDN = "CN=My Command,CN=Custom Commands,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes" # TODO: modify me

# Get the list of countries
$countries = [CultureInfo]::GetCultures([System.Globalization.CultureTypes]::SpecificCultures) | ForEach-Object {(New-Object System.Globalization.RegionInfo $_.Name).EnglishName} | Select-Object -Unique | Sort-Object

# Prompt for credentials
$credential = Get-Credential

# Bind to the Custom Command
$command = $admService.OpenObject("Adaxes://$commandDN", $credential.UserName, $credential.GetNetworkCredential().Password, 0)

# Create new parameter
$parameter = $command.CreateParameter("ADM_PARAMETERTYPE_LIST")
$parameter.Name = $parameterName

# Add parameter values
$arrayList = New-Object "System.Collections.ArrayList"
foreach ($country in $countries)
    $predefinedValue = $parameter.CreateValue()
    $predefinedValue.Value = $country
$parameter.Values = $arrayList.ToArray()

# Update Custom Command
$parametersArray = $command.Parameters
$parametersArray += $parameter
$command.Parameters = $parametersArray

Thank you!

Related questions

0 votes
1 answer

I'm in the process of creating a Web interface for requesting IT accounts. Upon submission, I want to run a Powershell script that will create an item in a Sharepoint task list.

asked May 14, 2021 by sandramnc (820 points)
0 votes
1 answer
0 votes
1 answer

I have an ADP Sync scheduled task that modifies and creates users from a csv file. I also have reports that show new users created and management history for user ... ADP Sync scheduled task so that they only run after the ADP Sync task is complete?

asked Jan 7, 2020 by barberk (60 points)
0 votes
1 answer

I need a list of all the URLs that Adaxes creates in IIS on the server Adaxes is installed on.

asked Feb 6, 2020 by DaralenManta (20 points)
0 votes
1 answer

I am trying to see if I can implement this in Adaxes somehow to support role-based provisioning to external apps (using appropriate Powershell scripts) but struggling to work ... to invest in a full-blown role-based provisioning platform (would rather not!).

asked Dec 24, 2019 by Bernie (310 points)
2,807 questions
2,541 answers
65,094 users