Wednesday, August 14, 2013

Active Directory: List Default Containers for new Users and Computers

This following script lists the default containers set in Active Directory. Usually new computer accounts are created in Computers container and new users created in Users container. You can change these default locations using ReDirCmp and ReDirUsr commands (usually available in Domain controllers at C:\windows\system32).

This following script lists the default containers set in Active Directory. Usually new computer accounts are created in Computers container and new users created in Users container.  (Thanks Mike Crowley). I found this script at HERE.

$x = Get-ADObject -Filter {isCriticalSystemObject -eq $true} | Where {($_.objectclass -eq 'container' -or $_.objectclass -eq 'organizationalUnit') -and (-not ($_.DistinguishedName -like '*ForeignSecurityPrincipals,DC*')) -and (-not ($_.DistinguishedName -like '*CN=System,DC*')) -and (-not ($_.DistinguishedName -like '*Domain Controllers,DC*')) -and (-not ($_.DistinguishedName -like '*ForeignSecurityPrincipals*'))}

$x | ft *dname

The same Mike had better one line Powershell command that displays same info.

Get-ADDomain | Select UsersContainer, SystemsContainer

 

Since I found this information in a hard way, I blogged it. So you can find it. Smile

No comments:

Post a Comment

Followers

hit counter