Skip to content

Enumerating child objects

The following code sample outputs names of objects located in a specific Organizational Unit.

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

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

# Bind to the Organizational Unit
$ouDN = "OU=My OU,DC=domain,DC=com"
$ou = $admService.OpenObject("Adaxes://$ouDN", $NULL, $NULL, 0)

foreach ($child in $ou)
{
    Write-Host $child.Name
}
Import-Module Adaxes

$ouDN = "OU=My OU,DC=domain,DC=com"

$ou = Get-AdmObject -Filter * -SearchBase $ouDN `
    -Server "domain.com" -SearchScope OneLevel `
    -AdaxesService localhost 

foreach ($child in $ou)
{
    Write-Host $child.Name
}

See also