@echo off ::IPMAC.BAT ::Jeffery Hicks ::jhicks@jdhitsolutions.com ::http://jdhitsolutions.blogspot.com ::Build a comma delimited file of computername,user,IPAddress,MAC address. ::Usage - ipmac [computername] ::********************************************************************************* ::* THIS PROGRAM IS OFFERED AS IS AND MAY BE FREELY MODIFIED OR ALTERED AS * ::* NECESSARY TO MEET YOUR NEEDS. * ::* THE AUTHOR MAKES NO GUARANTEES OR WARRANTIES, EXPRESS, IMPLIED OR OF ANY * ::* OTHER KIND TO THIS CODE OR ANY USER MODIFICATIONS * ::* DO NOT USE IN A PRODUCTION ENVIRONMENT UNTIL YOU HAVE TESTED IN A SECURED LAB * ::* ENVIRONMENT. USE AT YOUR OWN RISK. * ::********************************************************************************* ::To build a list, execute this command at a prompt - :: for /f %i in (computerlist.txt) do @ipmac %i 1>>ipmac.csv 2>>errors.txt ::Your comma delimited file will be saved to ipmac.csv and any errors will be captured ::in errors.txt. You may need to parse out the "Can't Verify" errors with the command - :: find /v /i "can't verify" ipmac.csv|find /v "---" >ipmacrev.csv ::OSCHECK if not "%OS%"=="Windows_NT" GOTO NOTNT ::SYNCHECK if %1$==$ GOTO NOPARAM if /i {%1}=={/?} GOTO HELP :MAIN set tmp1=%TEMP%\$iptmp1.tmp set tmp2=%TEMP%\$iptmp2.tmp set mactmp= set mac= set usrtmp= if exist %tmp1% del %tmp1% >NUL if exist %tmp2% del %tmp2% >NUL for /f "delims== tokens=2" %%i in ('nbtstat -a %1^|find "MAC Address"') do @set mactmp=%%i for %%i in (%mactmp%) do @set mac=%%i for /f %%i in ('nbtstat -a %1^|find "<03>"^|find /i /v "%1"') do @set usrtmp=%%i for /f "tokens=3" %%i in ('ping -n 1 %1^|find "Pinging"') do @echo %%i >%tmp1% REM if ping failed we don't want to continue if NOT exist %tmp1% GOTO ERR for /f "delims=[" %%i in (%tmp1%) do @echo %%i >%tmp2% for /f "delims=]" %%i in (%tmp2%) do @echo %1,%usrtmp%,%%i,%mac% if exist %tmp1% del %tmp1% >NUL if exist %tmp2% del %tmp2% >NUL set tmp1= set tmp2= set mactmp= set mac= set usrtmp= GOTO OUT :ERR ECHO Can't verify %1 GOTO OUT :NOTNT ECHO. ECHO %0 ECHO This program requires Windows NT or Windows 2000 GOTO OUT :NOPARAM ECHO. Echo Missing Parameter :HELP echo. echo IPMAC.BAT echo usage: ipmac [computername] echo example: ipmac flintsone echo. echo Do NOT use \\ before the computername. echo ipmac /? will display this help message echo. :OUT