Skip navigation

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


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 Configuration

	Host Name . . . . . . . . . : JSI001.JSI
	DNS Servers . . . . . . . . : 
	Node Type . . . . . . . . . : Mixed
	NetBIOS Scope ID. . . . . . : 
	IP Routing Enabled. . . . . : No
	WINS Proxy Enabled. . . . . : No
	NetBIOS Resolution Uses DNS : No

Ethernet adapter Elnk31:

	Description . . . . . . . . : ELNK3 Ethernet Adapter.
	Physical Address. . . . . . : 00-10-AC-30-1E-34
	DHCP Enabled. . . . . . . . : No
	IP Address. . . . . . . . . : 23.15.1.10
	Subnet Mask . . . . . . . . : 255.255.255.0
	Default Gateway . . . . . . : 23.15.1.10

Ethernet adapter NdisWan4:

	Description . . . . . . . . : NdisWan Adapter
	Physical Address. . . . . . : 00-00-00-00-00-00
	DHCP Enabled. . . . . . . . : No
	IP Address. . . . . . . . . : 0.0.0.0
	Subnet Mask . . . . . . . . : 0.0.0.0
	Default 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:\Admin\IPConfig.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 "<Drive:>:\folder1\JSIipMAC.CSV" "<Drive:>:\folder2\JSI Domain Members.DAT" "AdminShare\IPConfig.log"

JSIipMAC C:\folder1\JSIipMAC.CSV "\\Server\Share\JSI Domain Members.DAT" "C$\Admin\IPConfig.log"

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

JSIipMAC.bat contains:


@echo off
setlocal
If %1

"" goto syntax if %2

"" goto syntax if %3

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

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

"PhysicalAddress......" goto mac if /i %test%

"IPAddress........." goto ip goto end :mac set macadd=%3 goto end :ip set ipadd=%3 set ipadd="%ipadd:~2,99% if %ipadd%=="0.0.0.0" goto end set macadd=%macadd:~2,99% set ipadd=%ipadd:"=% set macadd=%macadd:"=% @echo %1,%ipadd%,%macadd% >> %rpt% :end

Hide comments

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