
I’m an old command line guy so:
For Domain CORP.MYCORP.COM
(You could use DomainRoot depending on what you are looking to do.)
Searching in OU=People
To find the distinguished names of users:
Default gives distinguished names of oubjects.
intersting switches in this case: -disabled | -o SAMID
add -disabled to the DSQuery to only pull disabled objects
dsquery user OU=People,DC=CORP,DC=MYCORP,DC=COM -scope subtree -limit 60000
To get a listing of information that includes the home directory set in AD:
dsquery user OU=People,DC=CORP,DC=PEP,DC=PVT -scope subtree -limit 10 | dsget user -disabled -samid -hmdir
If you don’t set Home Directory in AD, I hope it has SAMID within the directory structure to allow you to search / find on it to match to IDs.
A simple FOR loop can parse the information and move directories of disabled accounts to a holding location.
Using a more complex FOR loop with logic you could drop a flag files in directories of active users and inactive users.
Using the flag file as a basis you can parse directoried to find those not associated with an existing ID.














