Posted on 2006-04-20
Last Modified: 2012-06-27

I have like 5000 computers in my active directory and I need to put on the computer description (in active directory) the logged user and the computer model. I know that there is a WMI script that allow to do this but dunno how to make it.

I have a .BAT script that updates the user name but I think that in order to use it I need to use .vsb script.

this is the script I have

@echo off
set Machine=%computername%
set Description=%USERNAME%
for /f "delims=" %%a in ('dsquery computer -name "%Machine%"') do set MachineDN=%%a
dsmod computer %MachineDN% -desc %Description%

I am giving 500 points as I need to do this assap or my boss is gonna kill me. Thanks
Question by:Pollin
    LVL 70

    Accepted Solution


    Could you just check these are the bits you're after from the PC (will run for your local machine at the moment)? It just echos out the Model and User that's logged on. All in VbScript (.vbs).

    Const WBEM_FORWARD_ONLY = &H20

    strComputer = "."

    Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\CIMV2")

    Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_ComputerSystem", "WQL", _

    For Each objItem in colItems
          WScript.Echo objItem.Model
          WScript.Echo objItem.UserName
    Set colItems = Nothing

    If that is what you're after then it's quite simple to wrap everything else in so this updates the computer description. It will require a bit of checking to make sure it updates correctly.


    Author Comment

    Thanks Chris, You are a Star!!!!
    LVL 70

    Expert Comment

    by:Chris Dent

    Pleasure :)

    I take it you'll have no problems getting it to write back to the computer account from there?


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Many of us need to configure DHCP server(s) in their environment. We can do that simply via DHCP console on server or using MMC snap-in on each computer with Administrative Tools installed in a network. But what if we have to configure many DHCP ser…
    Setting up a Microsoft WSUS update system is free relatively speaking if you have hard disk space and processor capacity.   However, WSUS can be a blessing and a curse. For example, there is nothing worse than approving updates and they just have…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

    758 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

    10 Experts available now in Live!

    Get 1:1 Help Now