Subscribe to Windows IT Pro
July 21, 2004 12:00 AM

JSI Tip 8278. How do I use the NET VIEW command to return the computer names in my domain?

Windows IT Pro
InstantDoc ID #81379
Rating: (0)

Using the NET VIEW command, I have scripted NetViewC.bat to return all the computer names in a domain.

The syntax for using NetViewC.bat is:

for /f "Tokens=*" %%c in ('netviewc [NetBIOS_Domain_Name]') do (
 call :process %%c
)
...
...
:process

                  OR

setlocal ENABLEDELAYEDEXPANSION
for /f "Tokens=*" %%c in ('netviewc [NetBIOS_Domain_Name]') do (
 set computer=%%c
 ...
 ...
)
Where NetBIOS_Domain_Name is an optional parameter, unless you are logged on locally.

NOTE: If the NET VIEW /DOMAIN:NetBIOS_Domain_Name command does NOT return all the computer names in the domain, see the following:

How do I diagnose and test TCP/IP or NetBIOS network connections in Windows Server 2003?

When you use the NET VIEW command to view a different computer in your domain you receive 'An extended error has occurred'?

When you connect to a Windows 2000 server using an alias, you receive 'System error 52 has occurred'?

How can I retrieve, or set, the NetBIOS over TCP/IP setting for an interface?

NetViewC.bat contains:

@echo off
setlocal
set dom=%1
if defined USERDNSDOMAIN if not defined dom set dom=%USERDOMAIN%
if not defined dom goto :err
for /f "Tokens=1" %%c in ('net view /domain:%dom%^|Findstr /L /C:"\\"') do (
 @echo %%c
)
endlocal
goto :EOF
:err
@echo NetViewC - a NetBIOS domain name parameter is required because you are logged on locally to %USERDOMAIN%.
endlocal



Related Content:

ARTICLE TOOLS

Comments
    There are no comments to display. Be the first one!
You must log on before posting a comment.

Are you a new visitor? Register Here

advertisement

advertisement

Windows is a trademark of the Microsoft group of companies. Windows IT Pro is used by Penton Media Inc. under license from owner.