Thursday, March 3, 2011

Computer Cleanup Script – Batch File

Here is my first blog after the vacation Smile 

I created a simple batch file script based on a question posted on the TechNet Forum. This script can be used to

1. Count no of inactive computers in an AD domain,

2. Disable all inactive computer accounts and

3. Move them to an OU

Here is the script information:

@echo off

dsquery computer -inactive 4 > C:\InactiveComuter.txt

@echo No of Inactive Computers:

dsquery computer -inactive 4 | find "CN=" /c

@echo Disabling Computers

dsquery computer -inactive 4 | dsmod computer -disabled Yes

@echo Moving Computers

FOR /f %%i in (C:\InactiveComuter.txt) do (

dsmove %%i -newparent OU=Inactive,DC=infralab,DC=local

)

2 comments:

It’s really an interesting fact which I just got to know via this blog. Making this blog and keeping it updated is the best possible thing which customer always ask for. So I would like to thank for this interesting knowledge given by the moderator!
http://www.refurbished-computers.com

Really good procedure to clean inactive computer accounts in AD environment but I found good utility(http://www.lepide.com/active-directory-cleaner/) 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.

Post a Comment

Popular Posts

Share

Twitter Delicious Facebook Digg Stumbleupon Favorites More