active-directory – How to Remove Old Computers from a Domain

active-directorywindows

The Windows Domain I manage has hundreds of computer names which I don't recognise and I'd like to remove old ones which aren't in use before trying to track down the misnamed ones.

Is there someway to see when the last time a machine logged onto the network? Either via dhcpd or a user login event or something else.

Best Answer

You can use dsquery (technet link) to locate inactive computers:

dsquery computer -inactive 10 -limit 0

Shows computers that have been inactive for 10 weeks or more.

From dsquery computer /? (technet link)

...
-inactive <NumWeeks>        Finds computers that have been inactive (stale)
                            for at least <NumWeeks> number of weeks.
...

You can pipe the output into dsrm (technet link) if you want to remove the listing from the domain. Please note this will not bother prompting you so apply the appropriate amount of caution.

dsquery computer -inactive 10 -limit 0 | dsrm -noprompt