Help on a Windows batch file domain pc query?

Posted on 2006-03-30
Last Modified: 2013-11-13
I need to be able to query the domain and take all the computer names in the domain name put them into a text file. Then I need to take those results and use them to query all the computer for their system info (name, ip ,mac) Like the DOS systeminfo command with the mac address. And save the ouput as a .csv file that contains all the information for all computers in the domain. I have alot of seperate parts ,but can't tie it al together that good. Any help is appreciated.
Question by:sliderwing
    LVL 1

    Expert Comment

    It's tough to query all the remote machines in real time but pretty easy to set up a login script that queries the PC and writes a CSV out on a network share. Is that a possibility? The simplest script would just be one line:

    set > \\server\share\%computername%.txt
    LVL 10

    Expert Comment

    you can also add another line (if you are going with uter solution) for ip addresses, mac address and computer name ..etc like this:

    ipconfig /all >> \\server\share\%computername%.txt

    nothe that the >> will append to the file, not delte it.

    hope this help
    LVL 1

    Expert Comment

    If you really want to get fancy, you can do a

    fsutil fsinfo drives

    which will list all the drives, then parse those with a for loop and do a

    fsutil volume diskfree [drive letter]

    to get the free space.

    (Beat THAT for obscure DOS commands!) :-)


    Author Comment

    It is a weird scenario. I have no control over the servers, but total control over about 100 pc's running windows xp. So I won't be able to do the server thing. Thanks though.
    LVL 5

    Accepted Solution

    You can use the following program to get the information that you require with out the need to have access to the server. It will also automatically export to CSV and scans the network quite quickly.

    NBTscan is a program for scanning IP networks for NetBIOS name information. It sends NetBIOS status query to each address in supplied range and lists received information in human readable form. For each responded host it lists IP address, NetBIOS computer name, logged-in user name and MAC address.

    Example Usage-

    nbtscan.exe -q -s , > list.csv
    nbtscan.exe -q -s , > list.csv

    just use the above commands in a batch file and replace the IP ranges with your own.
    LVL 5

    Expert Comment

    Also have a look at PSTools especially PsExec

    PsExec will allow you to run programs remotely over a whole network of computers. The only problem is that it requires you to have a list of al of the computers on the domain. Although you could probably use nbtscan for that or some other tool.

    Expert Comment

    When you said 'domain', do you have Active Directory? You can start your PC name list by exporting the contents of the Users and Computers tool, Computers folder.

    The reverse approach, Make an Excel spreadsheet: put the text string "ping -n 1 -a 192.168.0." in cell A1 and copy it down to A254. (change the 192 part to match your IP addresses).
    In B1, type 1, then in B2 type 2, use the pattern fill to complete the series down to cell B254.
    In C1 type " >c:\pinglog.txt" and copy this all the way down to C254
    Save as a text file, open it in notepad
    Do a Find/Replace to remove the " and , and then save, rename to ping.bat and run it.

    You can do "arp -a" for a list of IP to mac addresses shortly after your scan finishes or change the batch file above to nbtstat -A

    These batch file approaches let you inventory your network, but require the PCs to be turned on.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Free camera licenses with purchase of My Cloud NAS

    Milestone Arcus software is compatible with thousands of industry-leading cameras for added flexibility. Upon installation on your My Cloud NAS, you will receive two (2) camera licenses already enabled in the software. And for a limited time, get additional camera licenses FREE.

    One of the most often confused topics in the area DNS is the idea of GLUE records. Specifically, what they are, when they are needed, when they are provided, and how they are created. First, WHAT IS GLUE? To understand GLUE, you must first under…
    Data center, now-a-days, is referred as the home of all the advanced technologies. In-fact, most of the businesses are now establishing their entire organizational structure around the IT capabilities.
    Viewers will learn how to connect to a wireless network using the network security key. They will also learn how to access the IP address and DNS server for connections that must be done manually. After setting up a router, find the network security…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    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