Skip navigation

JSI Tip 3459. How do I use Windows 2000 to generate a CSV containing all the computer names, IP addresses, and MAC addresses in my domain?

In tip 0835, I built a CSV ( Comma Seperated Values) from Windows NT.

In this script, I use NETDOM, from the Windows 2000 Support folder on the CD-ROM, GetMAC, from the Windows 2000 Server Resource Kit Supplement, and the Packet Inter Net Groper.

The script must run on any Windows 2000 computer, but the 'PDC' might be faster. The domain can be Windows NT, Windows 2000, or Mixed.

The CSV file will be similar to:

JSI001.JSIINC.COM and JSI005                               - are computer names. and                               - are IP addresses.
00-50-DA-17-3D-80 and 00-50-DA-66-2B-16                    - are MAC addresses.
\Device\NetBT_Tcpip_\{F651A57B-7286-42BF-A0D4-06C386EC5B77\} - is a Transport Name.
NOTE: JSI001 is multi-homed.

The script, MacIpCsv.bat, requires 1 parameter, the output file. MacIpCsv.bat contains:

@echo off
if \{%1\} EQU \{\} goto syntax
set outfile=%1
if exist %outfile% del /q %outfile%
For /f "Skip=1 Tokens=1" %%i in ('netdom query /domain PDC') do call :computer "%%i" 
For /f "Skip=1 Tokens=1" %%i in ('netdom query /domain DC') do call :computer "%%i" 
For /f "Skip=1 Tokens=1" %%i in ('netdom query /domain SERVER') do call :computer "%%i" 
For /f "Skip=1 Tokens=1" %%i in ('netdom query /domain WORKSTATION') do call :computer "%%i" 
goto end
@echo Syntax: macipcsv outputfile
goto end
set machine=%1
set machine=%machine:"=%
if "%machine%" EQU "The" goto end
if "%machine%" EQU "Directory" goto end
for /f "Skip=1 Tokens=2 Delims=\[\]" %%j in ('ping -n 1 %machine%') do @set ip=%%j
for /f "Skip=4 Tokens=1,2" %%m in ('getmac \\%machine%') do @if "%%m" NEQ "00-00-00-00-00-00" @echo %machine%,%ip%,%%m,%%n>>%outfile%

Hide comments


  • Allowed HTML tags: <em> <strong> <blockquote> <br> <p>

Plain text

  • No HTML tags allowed.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Lines and paragraphs break automatically.