How to find out inactive computers from Active Directory OU and clean them
How to find out inactive computers from Active Directory OU and clean them
Dsquery is a command-line tool that is built into Windows Server 2008 to find out the inactive computers or search criteria that you specify. Also we can use the dsmod and dsrm tool to disable or delete these objects at the same time.
There are two steps in this process and its explained below
Steps 1 –Find out inactive Computers from OU
Open elevated command prompt on DC and then type in
dsquery computer <distinguish name of the OU> –inactive <weeks> -limit <number> > c:computer.txt
Example
If you want to find out the 90 days inactive computers from specific OU
dsquery computer OU=TEST,DC=Ibsarabia,DC=com –inactive 12-limit500> c:computer.txt
–inactive 12: inactive in past 12 weeks (90 days)
-limit 500: limit the max entry to 500 in case there are too many objects
Steps 2 – Delete/Disable inactive computers
Pleases see below steps disable or delete these inactive objects after analyzing the computer.txt file.
To disable these objects:
type c:computer.txt | dsmod computer –disabled yes
To delete these objects:
type c:computer.txt | dsrm –noprompt -c
If you have any questions, please drop me an email
Hey there! I’m at work surfing around your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the superb work!
Try this tool for advanced way to track the inactive users and computers
You can manage the inactive users through this Inactive Account Tracker.
http://www.adsysnet.com/asn-active-directory-inactive-account-tracker-download.aspx
Nice power-shell script to find out inactive computers from AD but you can try this AD management (http://www.activedirectorymanagement.org/ ) for managing all active directory task and get report.
thanks for blog.
by the way, i encounter the below error message when input the command “type c:\computer.txt | dsmod computer –disabled yes”
“dsmod failed:You must specify at least one attribute to be modified.”
You can also automate it all by using tools like Adaxes http://www.adaxes.com/tutorials_AutomatingDailyTasks_DeleteInactiveComputersFromActiveDirectory.htm