Using the Active Directory command-line tools and information from How do I know what attribute names to use when performing a 'DSQUERY *'?, I have scripted SetCDName.bat to set the computer description in Active Directory equal to the logged on UserName.

The syntax for using SetCDName.bat is:

SetCDName \[NONE\]

Where NONE prevents prefixing the UserName with User=.

NOTE: Descriptions that already begin with User= are not updated, allowing you to run SetCDName.bat several times, to insure you get all descriptions updated.

NOTE: SetCDName.bat uses WhoConsole.bat and WhoConsole.vbs.

SetCDName.bat contains:

@echo off
set prefix=User=
if /i \{%1\}==\{NONE\} set prefix=%1
set q1=dsquery * domainroot -filter "(&(objectCategory=Computer)(objectClass=Computer))"
set q2=-attr distinguishedName name description -L -Limit 0
set /a cnt=0
for /f "Tokens=1* Delims=:" %%a in ('%q1% %q2%') do (
 set p1=%%a
 set p2=%%b
 call :attr
goto :EOF
set /a cnt=%cnt% + 1
if /i "%p1%" EQU "name" set name=%p2:~1%&goto t3
if /i "%p1%" EQU "description" set desc=%p2:~1%&goto t3
if /i "%p1%" EQU "distinguishedName" set dn=%p2:~1%
if %cnt% EQU 3 call :chkdesc
goto :EOF
set /a cnt=0
if "%desc%" EQU "" goto who
if /i "%prefix%" EQU "NONE" goto who
if "%desc:~0,5%" EQU "%prefix%" goto :EOF
call WhoConsole.bat %name% user
if "%user%" EQU "null" goto :EOF
if /i "%prefix%" EQU "NONE" set desc=%user%&goto update
set desc=%prefix%%user%
dsmod computer "%dn%" -desc "%desc%"