Tracking laptop asset tags/serial numbers using WMI and writing to Active Directory

I have an Active Directory network. I need to keep track of my laptops. I already have used Group Policy to push a Login script that adds all the current printers to users computers when they log in. I know how to get the asset tags/serail numbers using vbscript and WMI from each laptop. Is there a way to update an Active Directory property using a login script?
gepetersAsked:
Who is Participating?
 
RobSampsonConnect With a Mentor Commented:
Hi, as long as your users are able to update their own AD object, you can use code such as this to set the description of the user account to the serial number of the computer they are using.

Regards,

Rob.
Const wbemFlagReturnImmediately = &h10
Const wbemFlagForwardOnly = &h20
 
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT SerialNumber FROM Win32_BIOS", "WQL", wbemFlagReturnImmediately + wbemFlagForwardOnly)
 
For Each objItem In colItems
	strSerialNumber = objItem.SerialNumber
Next
 
Set objSysInfo = CreateObject("ADSystemInfo")
Set objUser = GetObject("LDAP://" & objSysInfo.UserName
objUser.Description = strSerialNumber
objUser.SetInfo
Set objSysInfo = Nothing

Open in new window

0
 
RobSampsonCommented:
Thanks for the grade.

Regards,

Rob.
0
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.

All Courses

From novice to tech pro — start learning today.