Enumerating child objects
The following code sample outputs names of objects located in a specific organizational unit.
- ADSI
-
[Reflection.Assembly]::LoadWithPartialName("Softerra.Adaxes.Adsi") # Connect to the Adaxes service $ns = New-Object "Softerra.Adaxes.Adsi.AdmNamespace" $service = $ns.GetServiceDirectly("localhost") # Bind to the organizational unit $ouDN = "OU=My OU,DC=domain,DC=com" $ou = $service.OpenObject("Adaxes://$ouDN", $null, $null, 0) foreach ($child in $ou) { Write-Host $child.Name }
- PowerShell
-
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 }