Add info to description in AD from list

Hello Experts!!!

I have a .csv of (Column A) Computer Names and (Column B) Serial Numbers saved on my hard drive.  (Can also use txt)

My task is to update the description for each Computer Account in Active Directory with its corresponding Serial Number.

I would like a script (PS, bat, VBscript, etc) to add the Serial Number from Column B to the current description of the corresponding Computer Name in Column A in Active Directory.  (I do not want to clear out any current description.  If there is a description, I would simply like to add the SN to the end.)


Any assistance is appreciated.




------------------------------------------------------------
Not Completely Relevant Information Below:
------------------------------------------------------------
My only previous experience with this was modifying all of the descriptions to say the same thing as seen below.  But I'm not sure how to add a unique description to each computer account.  I had to do this from an Exchange server itself also.  I no longer have rights to log onto an Exchange server so must do it from my workstation with domain admin rights.

Previous .cmd I used to do a mass description change (run from Exchange Server):

@echo off
set ComputerList=C:\LocationOfMyComputerList.txt
for /f "delims=" %%a in ('type "%ComputerList%"') do (
  echo Processing %%a ...
  dsquery computer -name "%%a" | dsmod computer -desc "Mass Description Here"
)
IrrylynAsked:
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.

SubsunCommented:
Try this code..
Import-Module Activedirectory
Import-Csv C:\computer.csv | %{
$Comp = $_
Write-Host "Working on $($Comp.Computer)"
 Try {
 Set-ADComputer $Comp.Computer -Description `
 ("$((Get-ADComputer $Comp.Computer -Pr Description -EA Stop).Description) $($Comp.SN)") -EA Stop
	New-Object PSObject -Property @{
	Computer = $Comp.Computer
	SN = $Comp.SN
	Update = "Success"
	}
 }
 Catch{
	New-Object PSObject -Property @{
	Computer = $Comp.Computer
	SN = $Comp.SN
	Update = "Failed"
	}
 }
} | Select Computer,SN,Update | Export-Csv c:\report.csv -nti

Open in new window

Sample csv file..
Computer,SN
ServerA,AAAAA
ServerB,BAAAA
ServerC,CAAAA 

Open in new window

0

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
IrrylynAuthor Commented:
This worked perfectly!!!  Thank you.  It updated the description without replacing anything that was previously there, and also spit out a results file!  Wonderful, thank you!

10k computer accounts updated in minutes!
0
SubsunCommented:
Nice!..
0
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
Active Directory

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.