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.
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")
# 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
[void]$arrayList.Add($predefinedValue)
}
$parameter.Values = $arrayList.ToArray()
# Update Custom Command
$parametersArray = $command.Parameters
$parametersArray += $parameter
$command.Parameters = $parametersArray
$command.SetInfo()