Windows Tip Sheet

"Hey MAC, Where You At?"

Find and report on MAC addresses with these quick command line tips.

I’ve seen a number of requests from people looking for ways to find MAC addresses of computers on their network. One of the fastest ways is to use NBTSTAT at a command prompt:

S:\>nbtstat -a godot

Local Area Connection:

Node IpAddress: [172.16.10.101] Scope Id: []

      NetBIOS Remote Machine Name Table

Name        Type              Status
---------------------------------------------
GODOT       <00>  UNIQUE      Registered
JDHIT       <00>  GROUP       Registered

MAC Address = 00-0B-DB-1C-C0-5F

Tech Help—Just An
E-Mail Away

Got a Windows, Exchange or virtualization question or need troubleshooting help? Or maybe you want a better explanation than provided in the manuals? Describe your dilemma in an e-mail to the MCPmag.com editors at mailto:[email protected]; the best questions get answered in this column and garner the questioner with a nifty Redmond T-shirt.

When you send your questions, please include your full first and last name, location, certifications (if any) with your message. (If you prefer to remain anonymous, specify this in your message, but submit the requested information for verification purposes.)

You can also use the IP address of the target machine by using:

NBTSTAT -A ipaddress

The "-A" is case-sensitive.

If you’d like to streamline the output, you can use the FOR command to parse out the MAC address like this:

for /f "tokens=2 delims==" %m in ('nbtstat -a godot^|find "MAC Address"') do @echo MAC Address is%m

The great thing about this technique is that you don’t need any administrative permission on the remote system.

Building a report is pretty straightforward if you already have a list of computers to check:

For /f %c in (computers.txt) do @for /f "tokens=2 delims==" %m in ('nbtstat -a %c ^|find "MAC Address"') do @echo %c MAC Address is%m

This technique will only work on a local LAN segment and obviously is subject to any internal firewalls or other network restrictions.

If you like this idea and would like to see another variation, visit http://www.jdhitsolutions.com/scripts and take a look at the LogIPMAC batch file. This script will output the computername, IP and MAC in a CSV format. Combine this script with the FOR command to parse a computer list and you have a quick database of computer information.

About the Author

Jeffery Hicks is an IT veteran with over 25 years of experience, much of it spent as an IT infrastructure consultant specializing in Microsoft server technologies with an emphasis in automation and efficiency. He is a multi-year recipient of the Microsoft MVP Award in Windows PowerShell. He works today as an independent author, trainer and consultant. Jeff has written for numerous online sites and print publications, is a contributing editor at Petri.com, and a frequent speaker at technology conferences and user groups.

comments powered by Disqus
Most   Popular