The Problem
Have you ever created a new user or computer object, but you’re unable to find them in the Default Computers/Users container?
Perhaps someone moved the default location to another Organizational Unit [i.e. to make sure GPO’s applied correctly] .
In this case a quick and simple script will check which containers are configured for this task and it will check if they’re using default values or not.
The Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<# .NOTES =========================================================================== Created with: SAPIEN Technologies, Inc., PowerShell Studio 2015 v4.2.95 Created on: 11/3/2015 13:22 Created by: Robert Prüst Organization: powershellpr0mpt.com Filename: Find-DefaultUserComputerContainer.ps1 =========================================================================== .DESCRIPTION A description of the file. #> Import-Module ActiveDirectory -ErrorAction SilentlyContinue [array]$locations = 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*')) } foreach ($location in $locations) { $DistinguishedName = $location.DistinguishedName if ($location.ObjectClass -eq 'OrganizationalUnit') { $DefaultFolder = $false } else { $DefaultFolder = $true } $properties = @{ 'Location' = $DistinguishedName; 'DefaultFolder' = $DefaultFolder; } $obj = New-Object -TypeName PSObject -Property $properties $obj } |




One thought to “Script Dumpster: Find default AD containers for Users and Computers”