How to Find & Remove Old Computer Accounts from Active Directory

How To:

Find & Remove Old Computer Accounts from Active Directory


When a workstation is removed from the network and it or a new computer is not put back on the network with the same computer name, the computer account still exists in Active Directory. These accounts should be deleted from Active Directory.


1) login to a server that has the Active Directory Users & Computers snap-in.

2) open a command prompt

3) run this command: "dsquery computer –inactive 8 – limit 0”

a. this will return a list of all computers that have been inactive for 8 weeks and "-limit 0” will return a complete list vs limiting the list to the top x computers.

4) Verify that these computers are no longer on the network

5) Remove them from Active Directory by 1 of the following methods:

a. Open the Active Directory Users & Computers snap-in, find each computer, right-click on the computer, and select delete.

b. Open a command prompt and run: "dsquery computer –inactive 8 –limit 0 > out.txt” Open this file in notepad and add "dsrm” to the beginning of every line and adding "-noprompt” to the end of every line. Save the file as a .bat file and run from the command prompt. This will create a batch file to delete all of the inactive workstations.

Article ID: 31
Created: Wed, Jun 6, 2012
Last Updated: Wed, Jun 6, 2012
Author: Natural Networks NOC

Online URL: