Skip to main content

Get the Children of an Active Directory Container in PowerShell

Problem

You want to list all the children of an Active Directory container.

Solution

To list the items in a container, use the [adsi] type shortcut to bind to the OU in Active Directory, and then access the PsBase.Children property of that container:

$sales =

[adsi] "LDAP://localhost:389/ou=Sales,dc=Fabrikam,dc=COM"

$sales.PsBase.Children

Discussion

The solution lists all the children of the Sales OU. This is the level of information you typically get from selecting a node in the ADSIEdit MMC snapin. If you want to filter this information to include only users, other organizational units, or more complex queries.

If you need dedicated infrastructure for retrieving child objects from Active Directory containers with PowerShell, consider a USA Dedicated Server for greater control over directory management, organizational structures, PowerShell automation, system administration, and Windows-based workloads.

Help Category