Write Dell Service Tag to Description in Active Directory

Posted on 2010-01-06
Last Modified: 2012-05-08
I am wanting to run a script as through group policy that writes the dell service tag of a machine to the active directy description attribute for that computer. I normally get the service tag from the machine by typing "wmic bios get serialnumber" at a command prompt. I am not sure if that helps or not. My workstations are XP SP3 and Windows 7 Ent.

Does anyone have a way that I can do this using a script?
Question by:Joseph Moody
    LVL 26

    Accepted Solution

    This should work if you run the script as a computer startup script.  The startup script should run under the computer's credentials which should enumerate to the SELF permission on the computer object.  The SELF permission should have write the description.  Anyhow, here's the code.
    sn = GetSerialNumber
    Function GetSerialNumber
    	strComputer = "."
    	Set objWMIService = GetObject("winmgmts:" _
    	    & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
    	Set colBIOS = objWMIService.ExecQuery _
    	    ("Select * from Win32_BIOS")
    	For each objBIOS in colBIOS
    		GetSerialNumber = objBIOS.SerialNumber
    End Function
    Sub UpdateDescription(strDescription)
    	Set objSysInfo = CreateObject("ADSystemInfo")
    	Set objComputer = GetObject("LDAP://" & objSysInfo.ComputerName)
    	objComputer.Description = strDescription
    End Sub

    Open in new window

    LVL 21

    Author Closing Comment

    by:Joseph Moody
    That works perfect! Thank you for the quick reply and nice script!
    LVL 26

    Expert Comment

    Glad to help

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How does your email signature look on mobiles?

    Do your employees use mobile devices to reply to emails? With mobile becoming increasingly important to the business world, it is in your best interest to make sure that your email signature looks great across all types of devices.

    I had a question today where the user wanted to know how to delete an SSL Certificate, so I thought that I would quickly add this How to! Article for your reference. WHY WOULD YOU WANT TO DELETE A CERTIFICATE? 1. If an incorrect certificate was …
    Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
    This tutorial will walk an individual through the steps necessary to configure their installation of BackupExec 2012 to use network shared disk space. Verify that the path to the shared storage is valid and that data can be written to that location:…
    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…

    779 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

    14 Experts available now in Live!

    Get 1:1 Help Now