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

image
The following command will return all disabled computer account information:

dsquery computer –disabled

image

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

image 

dsquery command reference
dsrm command reference

32 comments:

Santhosh...Recently i'm doing assesment on sccm 2012 for my new company. Please provide me there is any download software on sccm 2012 and document for.

You can download System Center Configuration Manager 2012 Beta 2 from the following location:

http://www.microsoft.com/download/en/details.aspx?id=20961

You can also see some System Center Configuration Manager 2012 in the following TechNet link:

http://technet.microsoft.com/en-us/library/gg682041.aspx

Dear Santosh,

Thanks for all your Scripts and tips which makes the admin work easy.

Please help in getting a Domain Controller GP based computer script which can be used to install MS security patches (and other softwares ) to about 400 client machines ..

Really appreciate all your posts.

Thanks
Murali

Thanks Murali.

Please provide more information about requirement.

You can install software using this logic - http://portal.sivarajan.com/2010/05/installing-forefront-client-security.html
http://www.sivarajan.com/scripts/FCS_Install.txt

Hi Santosh,

We have got SCCM configured in client machines and used to get MS security patches and other software installed. Now it has ceased working and need to urgently patch near abt 500+ machies before the IT audit.Please suggest a method.

1.All the machines are added to a Domain.(Users doesn't have admin privilege)
2. Need to get all the patches installed in the respective dates.:)(Patched date should be around two days after it got released from MS)

Please help me with a GP start up script to accomplish the same.

Many Thanks,
Murali

I can also recommend a tool called netwrix inactive users tracker for this. We use this tool and it identifies/automatically deactivates all users who haven’t logged into AD for a specified number of days.

Hi Siva

I have a PDC and BDC in a same location now i want to migrate from old domain to new domain. So i want to ask how can i achieve this thing. Kindly Help

This comment has been removed by the author.

i want to do it on urgent basis. It will be gud for me if you can help me.

I would recommend ASN AD Inactive Account Tracker. Please visit https://www.adsysnet.com/asn-active-directory-inactive-account-tracker-features.aspx

There are many third party products out there. My goal was to provide a solution using built-in options or tools. This is not a place for advertisement.

I would like to share a very prominent application named Lepide active directory cleaner (http://www.lepide.com/active-directory-cleaner/ ) that is equipped with several prominent features and helps to easily locate user accounts that are obsolete or not in use for a long time by defining accurate inactivity period.
Further, you can take appropriate action to remove, disable or move them to another OU, depends upon your requirement.

You can also do it with Adaxes. http://www.adaxes.com/tutorials_AutomatingDailyTasks_DeleteInactiveComputersFromActiveDirectory.htm It automates the process and gives a lot of flexibility when setting things up

there's an important one that worked for me. add the -c parameter to skip errors and continue moving on!

dsquery computer -inactive 8 -limit 2000 | DSRM -subtree -noprompt -c

A GUI tool that helps with cleaning up your AD (old users, computers, user profiles, user home directories) is ADCleanup. You can check it out at http://wizardsoft.nl/admintools/admintools.html . Not too expensive.

There are many third party tools available. My goal was to provide to a native and free options for systems admins!

Hi Santosh,


I gone through your blog its good and helpful.

I want small help from you...


Till now i hope you worked on multiple AD issues which are meant to be critical. Can you please let me know 5 critical issues you faced for DNS, Replication and soon and how you resolved.


Thanks
Satya

Really good procedure to clean inactive computer accounts in AD environment but I found good article (http://www.esystool.com/cleanup-old-computer-accounts-in-active-directory/ ) to cleanup inactive computer accounts and manage inactive user/computer accounts, move the accounts to another OU. It's generate reports on inactive accounts, never logged on users and real last logon details of accounts in CSV, HTML and PDF format.

في مكان ما على طول الخط ، أصبحت الروائح مكونًا من مكونات 'نظيفة' على الرغم من أن عملية تنظيف الغسيل أو أي شيء آخر يتم لإزالة التربة وأي روائح. عندما تستخدم الغسالات صابون الغسول محلي الصنع لتنظيف الملابس ، كانوا يحاولون إزالة التربة وكذلك الروائح من الأجسام والبقع. ولكن في الوقت نفسه ، قاموا بتدبيس حزم من الخزامى المجفف لأنهم أحبوا الرائحة في جذوع لجعل رائحة الملابس أفضل.
شركة النجوم لخدمات التنظيف
شركة كشف تسربات المياه بالرياض
نصائح للقضاء على الحشرات
تنظيف السجاد

Download lucky patcher apk uptodown – latest version – Mod for Android to remove ads, make in-app purchases for free, and rewrite many apps to do what you want them to.

Hi.. I read your blog which is really great and Thanks for sharing. Keep posting. Must visit on facebook bellen

This comment has been removed by the author.

Your blog is very informative, finally, I found exactly what I want. Paypal is an excellent service for online payments but lots of its users confront issues while they access Paypal. If you want to resolve your problems then must visit Paypal klantendienst.

Hi, Thank you for sharing such a good and valuable information,It is very important for me. Gmail is the worldwide used email service but sometimes user faces some problems in it. If you want to get some information about the Gmail then you can visit Gmail-tili.

Unbelievable blog! This blog provides a brief introduction which is very helpful for me. Instagram is the most usable platform in the world because of its latest features but the user some time confronts some issues on Instagram. For more information, you can visit Instagram yhteystiedot.

The information you are providing that is really good. Thank for making and spending your precious time for this useful information. Thanks again and keep it up. https://www.akgvg.com

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More