Querying AD for dead computers

Soldato
Joined
25 Oct 2009
Posts
6,706
Location
Caerphilly
Afternoon,

I'm trying to source a solution to enable me to query an Active Directory server (Server 2003 and Server 2008) to find computers joined to the domain that have not talked back to Active Directory for a certain length of time (EG: 3 months) and then delete them accordingly (or run netdom to remove).

Anyone aware of such a script / bat file etc to do this? Google is turning up trumps at the moment.
Thanks.
 
I really wouldn't recommend deleting stale computer accounts, especially automatically - move to a separate OU and disable in the first instance.
 
Why hasn't DS been mentioned?

dsquery computer -inactive Xweeks | dsrm computer

or

dsquery computer -inactive Xweeks | dsget computer -samid

Or omit the piped information to get the OU location of it.

Peice of ****.
 
Last edited:
Powershell and the Quest AD cmdlets - I use PS all the time.

Beware of scripts on the MS script gallery site though - they often do things using very inefficient methods. There are often better ways of doing things.

Also, +1 for moving unused computers to their own graveyard rather than deleting them- - useful for proper CMDB asset tracking & inventory etc.
 
Back
Top Bottom