How to enumerate network computers from command line?

8,324

Solution 1

The formatting in "net view" is pretty crappy for parsing since it displays NetBIOS names and they can contain spaces. (Why anyone would actually use spaces is beyond me, though...)

If you're sure your computer names don't have spaces, do:

@echo off
for /f "usebackq delims= " %%i in (`net view ^| find "\\"`) do echo %%i

Obviously, substitute a call to another batch file or a command for the "echo".

Solution 2

There are many ways to enumerate systems; in fact I have a whole wiki page devoted to just this.

But one pretty nice way is with nbtscan, which will give you a list like this:

C:\> nbtscan 192.168.1.0/24
192.168.1.3     MTNDEW\WINDEV               SHARING DC
192.168.1.5     MTNDEW\TESTING
192.168.1.9     MTNDEW\WIZ                  SHARING U=STEVE
192.168.1.99    MTNDEW\XPDEV                SHARING
Share:
8,324

Related videos on Youtube

Jonathon
Author by

Jonathon

Updated on September 17, 2022

Comments

  • Jonathon
    Jonathon over 1 year

    I am on Windows XP and would like to enumerate the computers that exist on my network from a command line. I would like to enumerate them such that I can use the host names in another command, pslist . I suspect that I can use PowerShell and the "net view" command to do this, but can't iron out the specifics.

    • Admin
      Admin almost 15 years
      Are these domain or standalone computers?
    • Admin
      Admin almost 15 years
      Can they be read from Active Directory? I have a PS script that gets the list from AD.
  • Jonathon
    Jonathon almost 15 years
    This was exactly what I was looking for. Thank you.