Wednesday, March 24, 2010

Delete Stale or Inactive Computer Accounts from Active Directory

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

The following command will return all disabled computer account information:

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


dsquery command reference
dsrm command reference


Post a Comment

Popular Posts


Twitter Delicious Facebook Digg Stumbleupon Favorites More