Add info to description in AD from list

Posted on 2014-08-14
Last Modified: 2014-08-15
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"
Question by:Irrylyn
    LVL 40

    Accepted Solution

    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"
    	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..

    Open in new window


    Author Closing Comment

    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!
    LVL 40

    Expert Comment


    Featured Post

    Courses: Start Training Online With Pros, Today

    Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

    Join & Write a Comment

    Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
    Find out how to use Active Directory data for email signature management in Microsoft Exchange and Office 365.
    This tutorial will walk an individual through the steps necessary to join and promote the first Windows Server 2012 domain controller into an Active Directory environment running on Windows Server 2008. Determine the location of the FSMO roles by lo…
    This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    15 Experts available now in Live!

    Get 1:1 Help Now