• Home
  • About
    • Disclaimer
  • Archives
  • Tools

Trace and delete unused computer accounts with “dsquery”

Sep02
2011
Written by david

Over the years, computers are replaced or decommissioned from the network but computers accounts in active directory are not deleted automatically and become obsolete.

Tracing these accounts in the past wasn’t an easy task.

To trace these accounts in the directory the easyest way is to search the computers that have not been logged in to the network in a given time interval.

For example, the following command will find all computers in Active
Directory that have not logged in to the network in the past 10 weeks:

dsquery computer -inactive 10 -limit 0

After reviewing the output list and you determent that these computers are no longer exist on you network, you can run the following command to delete them:

dsquery computer -inactive 10 -limit 0 | dsrm

If you just want to disable these accounts, try this command:

dsquery computer -inactive 10 -limit 0 | dsmod computer -disabled yes
VN:F [1.9.20_1166]
please wait...
Rating: 0.0/10 (0 votes cast)
VN:F [1.9.20_1166]
Rating: +1 (from 1 vote)
Posted in Command Line, Windows - Tagged CMD, Command Line, dsquery, windows
SHARE THIS Twitter Facebook Delicious StumbleUpon E-mail
Similar posts
  • Windows Error Reporting (WER) and low... — I don’t use Widows Error Reporting service and it appears...
  • Windows Server 2008 R2, after install... — After installing Service Pack 1 on a few of my Windows 20...
  • Fix Event ID: 13555 — I got this error during a migration test of an SBS2003 to...
  • How to: shrink an SQL log file. — Once in awhile I meet an sql based program that won’...
  • You have been logged on with a tempor... — After deleting a user profile directory in windows 2008 t...
« FreeNAS 8 and stability issues!
» Find user location in Active Directory with “dsquery”

Categories

  • Command Line (11)
  • Exchange (8)
    • 2007 (4)
    • 2010 (5)
  • Fortigate (10)
  • FreeNAS (2)
  • HmailServer (1)
  • How To: (8)
  • MS SQL 2008 (4)
  • Networking (4)
  • Open Source (1)
  • PowerShell (2)
  • Recovery (1)
  • SBS (8)
    • SBS 2008 (6)
    • SBS 2011 (3)
  • Terminal Server (2)
  • Veeam (2)
  • VMware (6)
  • Windows (18)

Links

  • חי הדפסות – דפוס משי, חולון
  • שלישיה – זה לא מה שחשבתם

Archives

  • March 2018
  • January 2018
  • September 2015
  • January 2015
  • August 2014
  • May 2014
  • December 2013
  • January 2013
  • October 2012
  • September 2012
  • July 2012
  • June 2012
  • May 2012
  • January 2012
  • December 2011
  • November 2011
  • October 2011
  • September 2011
  • July 2011
  • June 2011
  • May 2011
  • April 2011
Site Meter

EvoLve theme by Theme4Press  •  Powered by WordPress How to do.....IT