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

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 off
setlocal
set netdm=netdom query /domain:%userdnsdomain% dc
for /f "Skip=1 Tokens=*" %%C in ('%netdm%') Do set cmp=%%C&call :getit
set netdm=netdom query /domain:%userdnsdomain% server
for /f "Skip=1 Tokens=*" %%C in ('%netdm%') Do set cmp=%%C&call :getit
set netdm=netdom query /domain:%userdnsdomain% workstation
for /f "Skip=1 Tokens=*" %%C in ('%netdm%') Do set cmp=%%C&call :getit
endlocal
goto :EOF
:getit
if "%cmp%" EQU "The command completed successfully." goto :EOF
set mac=
set work=%cmp:     ( Workstation or Server )=Unknown Computer Type%
if "%work%" NEQ "%cmp%" set cmp=%work%&goto out
for /f "Tokens=*" %%M in ('nbtstat -a "%cmp%" ^|findstr /L /C:MAC') do set mac=%%M
set mac=%mac:~14%
:out
@echo %cmp% %mac%



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