Wednesday, August 24, 2011

Clean Up your active directory

1- Using Hyena software go to respective OU and retrieve a list of Computers
or
dsquery computer "OU=WSUS,DC=ABC,DC=KW,DC=com" -limit 1000 > C:\WsusComputers.txt
or if it was under container use:
dsquery computer "CN=Computers,DC=ABC,DC=KW,DC=com" -limit 1000 > C:\WsusComputers.txt


2- Clean them up by Excel to allow only Computer name and then save them to file.

3- Use:
C:\>for /f %a in (C:\lookup.txt) do nslookup %a | find /i "Address" >> c:\nslookup_results.txt
to resolve them to IPs



4- Use angry IP scanner to resolve them to DNS again but with IPs matched & FqDN.

5- Export to Excel and filter to remove [ns] [na] invalid IPs

6- Move them to separate OU:
dsquery computer -name muhq-teller2.ABC.bh.com | dsmove -newparent ou=muharraq,ou=computers,ou=ABC,dc=kfh,dc=bh,dc=com

7- get list of inactive computers for last 90 days:
dsquery computer -inactive 90 -limit 0

And move them as above as well.

No comments: