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)
0

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?

0

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
0

Hello Mark,

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

0

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

1 Answer

0 votes
by (232k 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.
[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()
0

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

We have a 3rd party vendor that we are able to add users based on AD security groups. What I need to do is set a parameter for the number of available licenses and whenever ... the group is 495 I would like an email to trigger telling me to add more licenses.

asked Oct 12 by A_Pastor (70 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)
2,867 questions
2,590 answers
6,720 comments
109,114 users