Write Dell Service Tag to Description in Active Directory

Posted on 2010-01-06
Medium Priority
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
  • 2
LVL 26

Accepted Solution

Pber earned 2000 total points
ID: 26190636
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 22

Author Closing Comment

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

Expert Comment

ID: 26190702
Glad to help

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

After seeing many questions for JRNL_WRAP_ERROR for replication failure, I thought it would be useful to write this article.
This article provides a convenient collection of links to Microsoft provided Security Patches for operating systems that have reached their End of Life support cycle. Included operating systems covered by this article are Windows XP,  Windows Server…
This tutorial will walk an individual through configuring a drive on a Windows Server 2008 to perform shadow copies in order to quickly recover deleted files and folders. Click on Start and then select Computer to view the available drives on the se…
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Suggested Courses

850 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