Viewing custom command parameters

The following code sample displays the names, types, and IDs of all parameters of a specific custom command.

[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi")

$customCommandDN = "CN=My Command,CN=Custom Commands,CN=Configuration Objects,CN=Adaxes Configuration,CN=Adaxes"

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

# Bind to the custom command
$myCustomCommand = $service.OpenObject("Adaxes://$customCommandDN", $null, $null, 0)

# Output the list of parameters
foreach ($parameter in $myCustomCommand.Parameters)
{
    Write-Host "`nParameter name:" $parameter.DisplayName
    Write-Host "Identifier:" $parameter.Id
    Write-Host "Type:" $parameter.Type
        
    # Check box list 
    if ($parameter.Type -eq "ADM_PARAMETERTYPE_CHECKLIST") 
    {
        Write-Host "Checkbox items:"

        # Get each checkbox item Id
        foreach ($checkbox in $parameter.Items)
        {
            Write-Host "`n`tDisplay name:" $checkbox.DisplayName
            Write-Host "`tIdentifier:" $checkbox.Id
            
        }
    }
    # Drop-down list
    if ($parameter.Type -eq "ADM_PARAMETERTYPE_LIST") 
    {
        Write-Host "Drop-down list items:"

        # Get each drop-down list value Id
        foreach ($listItem in $parameter.Values)
        {
            Write-Host "`n`tDisplay name:" $listItem.DisplayName
            Write-Host "`tValue:" $listItem.Value
            Write-Host "`tIdentifier:" $listItem.ID 
            
        }
    }
}

For information on how to get the distinguished name (DN) of a custom command, see Get the DN of a directory object.

See also