Computer Description in Active Directory

J

Jerold Schulman

Is there a way to pull the Computer Description from a
machine into Active Directory?

Using information from tips 6820, 7992, and links in the 'Tips & Tricks' at
http://www.jsiinc.com, I have scripted updcompdesc.bat.

When you run updcompdesc.bat, it displays the computer accounts that it updated,
like:
dsmod succeeded:CN=JSI009,CN=Computers,DC=JSIINC,DC=COM
dsmod succeeded:CN=JSI007,CN=Computers,DC=JSIINC,DC=COM


updcompdesc.bat contains:

@echo off
setlocal
set q1=dsquery * domainroot -filter
"(&(objectCategory=Computer)(objectClass=Computer))"
REM the above 2 lines are 1 line
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
)
endlocal
goto :EOF
:attr
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%
:t3
if %cnt% EQU 3 call :chkdesc
goto :EOF
:chkdesc
set /a cnt=0
if "%desc%" NEQ "" goto :EOF
set dok=1
for /f "Skip=1 Tokens=*" %%v in ('net view \\%name%') do (
set work=%%v
call :view
)
if "%dok%" NEQ "3" goto :EOF
call :upd
goto :EOF
:view
if "%dok%" EQU "3" goto :EOF
if "%dok%" EQU "1" set desc=%work%&set dok=2&goto :EOF
if "%dok%" NEQ "2" goto :EOF
if "%work:~0,11%" NEQ "Share name " goto :EOF
set dok=3
goto :EOF
:upd
dsmod computer "%dn%" -desc "%desc%"


Jerold Schulman
Windows: General MVP
JSI, Inc.
http://www.jsiinc.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top