JSI Tip 7620. How do I record the MAC addresses in my domain from my desktop?

Jerold Schulman

December 30, 2003

1 Min Read
ITPro Today logo in a gray background | ITPro Today

Using the NETDOM.EXE and the Nbtstat.exe support tools, I have scripted DomMAC.BAT to return the computer name and MAC address off all domain computers.

The syntax for using DomMAC.BAT is:

DomMAC.

The output is displayed on the CMD console, but you can pipe it to a file:

DomMAC >FileName.txt.

DomMAC.BAT contains:

@echo offsetlocalset netdm=netdom query /domain:%userdnsdomain% dcfor /f "Skip=1 Tokens=*" %%C in ('%netdm%') Do set cmp=%%C&call :getitset netdm=netdom query /domain:%userdnsdomain% serverfor /f "Skip=1 Tokens=*" %%C in ('%netdm%') Do set cmp=%%C&call :getitset netdm=netdom query /domain:%userdnsdomain% workstationfor /f "Skip=1 Tokens=*" %%C in ('%netdm%') Do set cmp=%%C&call :getitendlocalgoto :EOF:getitif "%cmp%" EQU "The command completed successfully." goto :EOFset mac=set work=%cmp:     ( Workstation or Server )=Unknown Computer Type%if "%work%" NEQ "%cmp%" set cmp=%work%&goto outfor /f "Tokens=*" %%M in ('nbtstat -a "%cmp%" ^|findstr /L /C:MAC') do set mac=%%Mset mac=%mac:~14%:out@echo %cmp% %mac%



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