Active Directory

Ok here is what I'm wanting to do. I would like to update the computer description filed in Active Directory.  I have close to 200 PC's so I really would like an automated way.

I can do a Net View and it shows all the correct information on the computer description filed of the PC.  Now is there away to get that information into AD automatically maybe via a script or something?
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

karmstrongAuthor Commented:
I found this Bat file which should do the trick however I get an erorr any idea?

@echo off
set Machine=%1
set Description=%2
for /f "delims=" %%a in ('dsquery computer -name "%Machine%"') do set MachineDN=%%a
dsmod computer %MachineDN% -desc %Description%

dsquery failed:The search filter cannot be recognized.
type dsquery /? for help.dsmod failed:No value specified for `desc'.
type dsmod /? for help.
The above script will need two arguments when run, first the computer name and then the description (in quotation marks).
Try this: on a Server 2003 or an XP workstation with adminpak.msi installed (for the ds-tools), open a command prompt and enter
net view >Description.txt
This will create a text file with the computer names and their description; open it in notepad and remove the unnecessary first lines. Remove as well any lines you don't want processed (you can leave lines with empty description, those won't be processed).
Then save and run this script in the same directory as the Description.txt.

@echo off
setlocal enabledelayedexpansion
set DescFile=%~dp0Description.txt

for /f "tokens=1*" %%a in ('type "%DescFile%"') do (
  set Machine=%%a
  set TempDesc=%%b
  call :process
goto leave

set Machine=%Machine:\=%
set Desc=
for %%a in (%TempDesc%) do set Desc=!Desc! %%a
if "%Desc%"=="" goto :eof
set Desc=%Desc:~1%
echo Processing %Machine%: %Desc%
dsquery computer domainroot -samid "%Machine%$" | dsmod computer -desc "%Desc%"
goto :eof


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
karmstrongAuthor Commented:
I get the fallowing message

| was unexpected at this time.
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

Do you have special characters in your descriptions, like | < > ^ & % or quotation marks?
karmstrongAuthor Commented:
Yep sure did
worked Perfect thanks

One last question KNow of a script to clean out old computer names no longer used in AD?
You can do that with dsquery.exe:
dsquery computer domainroot -limit 0 -inactive <number of weeks>
will give a list of computers that haven't logged on in <number of weeks> weeks.
Yep, and pipe it to DSRM.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows Server 2003

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.