Powershell – How to enumerate network computers from command line

command-line-interfacehostnamenetworkingpowershell

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.

Best Answer

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".