Using the Active Directory command-line tools, I have scripted DisAbleComputer.bat to disable a computer account, and to prefix its' description with the 'DISABLED YYYY/MM/DD ' string.

The syntax for using DisAbleComputer.bat is:

\[call\] DisAbleComputer ComputerName

Where ComputerName is the NetBIOS computer name of the computer you wish to disable.

NOTE: DisAbleComputer.bat uses Univdate.bat, which must be placed in a folder that is in your PATH.

DisAbleComputer.bat contains:

@echo off                              if \{%1\}==\{\} @echo Syntax: \[call\] DisAbleComputer ComputerName&goto :EOF                              setlocal                              set comp=%1                              for /f "Tokens=*" %%d in ('dsquery computer -name %comp% -O DN') do (                               set DN=%%d                              )                              if defined DN goto getdesc                              @echo Syntax: DisAbleComputer - %comp% NOT found.                              endlocal                              goto :EOF                              :getdesc                              for /f "Skip=1 Tokens=*" %%d in ('dsget computer %DN% -desc^|findstr /v /c:"dsget succeeded"') do (                               set desc=%%d###                              )                              set desc=%desc:  ###=%                              for /f "Skip=1 Tokens=*" %%d in ('dsget computer %DN% -disabled^|findstr /v /c:"dsget succeeded"') do (                               set dis=%%d                              )                              if /i "%dis:~0,2%" EQU "no" goto getdate                              @echo Syntax: DisAbleComputer - %comp% previously disabled.                              endlocal                              goto :EOF                              :getdate                              call UnivDate                              set /a yy=10000%yy%%%10000                              set /a mm=100%mm%%%100                              set /a dd=100%dd%%%100                              if %mm% LSS 10 set mm=0%mm%                              if %dd% LSS 10 set dd=0%dd%                              if %yy% LSS 1000 set yy=20%yy%                              for /f "Tokens=*" %%d in ('dsmod computer %DN% -disabled yes -desc "DISABLED %yy%/%mm%/%dd% %desc%"') do (                              set success=%%d                              )                              if /i "%success:~0,16%" EQU "dsmod succeeded:" goto finish                              @echo Syntax: DisAbleComputer - %comp% failed to update?                              endlocal                              goto :EOF                              :finish                              endlocal