JSI Tip 0835. How do I build and maintain a list of Computer Names, IP Adresses, and MAC Addresses for my domain?

Jerold Schulman

November 12, 1998

2 Min Read
ITPro Today logo


If you wish to create a CSV (Comma Seperated Value) file that contains Computer Name, IP Address, and MAC Address similar to:

JSI001, 23.15.1.10, 00-10-AC-30-1E-34
JSI002, 23.15.1.20, 00-10-AC-31-84-06
JSI003, 23.15.1.30, 00-10-AC-27-34-18

you can use the IPCONFIG /ALL command. The ouput of this command provides the following information:

Windows NT IP ConfigurationHost Name . . . . . . . . . : JSI001.JSIDNS Servers . . . . . . . . : Node Type . . . . . . . . . : MixedNetBIOS Scope ID. . . . . . : IP Routing Enabled. . . . . : NoWINS Proxy Enabled. . . . . : NoNetBIOS Resolution Uses DNS : NoEthernet adapter Elnk31:Description . . . . . . . . : ELNK3 Ethernet Adapter.Physical Address. . . . . . : 00-10-AC-30-1E-34DHCP Enabled. . . . . . . . : NoIP Address. . . . . . . . . : 23.15.1.10Subnet Mask . . . . . . . . : 255.255.255.0Default Gateway . . . . . . : 23.15.1.10Ethernet adapter NdisWan4:Description . . . . . . . . : NdisWan AdapterPhysical Address. . . . . . : 00-00-00-00-00-00DHCP Enabled. . . . . . . . : NoIP Address. . . . . . . . . : 0.0.0.0Subnet Mask . . . . . . . . : 0.0.0.0Default Gateway . . . . . . : Primary WINS Server . . . . : 23.15.1.10

The IPCONFIG /ALL command must run locally. If you pipe the output to a consistent location on each computer, you can retrieve, parse, and combine it.

There are a number of ways to accomplishing this, including scheduling the IPCONFIG /ALL command, placing it in a logon script, or including it in AUTOEXNT.BAT. I use the later method and pipe the output to C:AdminIPConfig.log on each server and workstation in my domain.

When I want an updated CSV, I run JSIipMAC.bat which has 3 required parameters:

1. The full path of the CSV file you want generated.

2. The full path to a file that contains computer names in my domain. See tip 677.

3. The ShareName\[folder]IPConfig.log on each computer.

Examples:

JSIipMAC ":folder1JSIipMAC.CSV" ":folder2JSI Domain Members.DAT" "AdminShareIPConfig.log"

JSIipMAC C:folder1JSIipMAC.CSV "\ServerShareJSI Domain Members.DAT" "C$AdminIPConfig.log"

Note: The quotes are only needed if the path has spaces.

JSIipMAC.bat contains:

@echo offsetlocalIf %1

"" goto syntaxif %2

"" goto syntaxif %3

"" goto syntaxif not exist %2 goto syntaxif exist %1 del /q %1set rpt=%1set comp=%2set cfgpath=%3set cfgpath=%cfgpath:"=%for /f %%i in ('type %comp%') do call :machine %%i endlocalgoto end:Syntax@echo Syntax: JSIipmac "Drive:PathUserRpt.txt" "Drive:PathComputer.txt" "ShareName\[path]iplog.log"endlocalgoto end:machineif not exist "\%1%cfgpath%" goto endfor /f "Tokens=1* Delims=:" %%i in ('type "\%1%cfgpath%"') do call :ipc %1 "%%i" "%%j"goto end:ipcset test=%2if %test%

"" goto endset test=%test: =%set test="%test:~2,99%if /i %test%

"PhysicalAddress......" goto macif /i %test%

"IPAddress........." goto ipgoto end:macset macadd=%3goto end:ipset ipadd=%3set ipadd="%ipadd:~2,99%if %ipadd%=="0.0.0.0" goto endset macadd=%macadd:~2,99%set ipadd=%ipadd:"=%set macadd=%macadd:"=%@echo %1,%ipadd%,%macadd% >> %rpt%:end


Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like