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

Posted on 2008-11-06
Last Modified: 2013-12-24
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?
Question by:gepeters
    LVL 65

    Accepted Solution

    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.


    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
    Set objSysInfo = CreateObject("ADSystemInfo")
    Set objUser = GetObject("LDAP://" & objSysInfo.UserName
    objUser.Description = strSerialNumber
    Set objSysInfo = Nothing

    Open in new window

    LVL 65

    Expert Comment

    Thanks for the grade.



    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    I annotated my article on ransomware somewhat extensively, but I keep adding new references and wanted to put a link to the reference library.  Despite all the reference tools I have on hand, it was not easy to find a way to do this easily. I finall…
    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 configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …

    761 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

    7 Experts available now in Live!

    Get 1:1 Help Now