Here is an easy way to identify and delete inactive or stale computers in an Active Directory environment. Using the dsquery command you can easily find all of the computers in the directory that have not been logged into in a given time interval or disabled.
The following command will return all computers that have been inactive or stale for 2 weeks:
dsquery computer –inactive 2
dsquery computer –disabled
You can combine this output with the dsrm command to delete these objects from Active Directory
dsquery computer –inactive 2 | dsrm -noprompt
dsquery computer –disabled | dsrm -noprompt