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.3k 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 (294k 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

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

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 (870 points)
0 votes
1 answer

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 ... I can't get it to work. Could you assist me in finding the best way to do this?

asked Jan 16 by dominik.stawny (280 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 (80 points)
3,588 questions
3,277 answers
8,303 comments
548,080 users