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.
December 30, 2003
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%
You May Also Like