getmac - Check MAC Addresses
Table of Contents
The getmac command lists the MAC addresses (physical addresses) of your PC’s network adapters.
A MAC address is an identification number assigned to each piece of network hardware. You need it for things like MAC address filtering on a router or managing network devices.
Basic Usage
getmac [/v] [/fo format] [/nh] [/s computer [/u user [/p password]]]
Run without arguments, it shows MAC addresses and transport names.
MAC addresses appear as pairs of hexadecimal digits joined by hyphens, like 00-1A-2B-3C-4D-5E.
The output above is only an example. MAC addresses and transport names differ on every PC. On a Japanese version of Windows, the headings and messages appear in Japanese.
Show Adapter Names Too (/v)
In the default output, it is hard to tell which address belongs to which adapter. Add /v to also show the connection name and adapter name.
getmac /v
The connection name corresponds to names such as “Ethernet adapter” and “Wireless LAN adapter” in ipconfig.
An adapter whose cable is unplugged, or that is not connected to Wi-Fi, shows “Media disconnected” instead of a transport name. To find the MAC address of the connection you are using now, look for the row whose transport name is \Device\Tcpip_....
Change the Output Format (/fo)
/fo sets the output format: TABLE (default), LIST, or CSV.
| Format | Description |
|---|---|
TABLE | Show as a table (default) |
LIST | Show one item per line |
CSV | Show as comma-separated values |
getmac /fo csv
CSV is handy when you save the output to a file with > and open it in Excel.
getmac /v /fo csv > mac.csv
Omit the Header (/nh)
/nh removes the header row. It works with the TABLE and CSV formats.
getmac /fo csv /nh
Check Another PC’s MAC Address (/s)
Specify a computer name or IP address with /s to get the MAC addresses of another PC on the network.
getmac /s PC-01 /u DOMAIN\username
You can pass the password with /p, but it can remain on screen or in your history, so it is better to omit it and type it when prompted.
You need administrator rights on the remote PC, and remote management must be allowed by its firewall and other settings. Use this only on PCs you are authorized to manage.
Extract the MAC Address in a Batch File
This example stores only the first adapter’s MAC address in a variable.
@echo off
for /f "tokens=1 delims=," %%a in ('getmac /fo csv /nh') do (
set MAC=%%~a
goto :done
)
:done
echo MAC address: %MAC%
Using /fo csv /nh gives headerless CSV, which is easy to handle with for /f. The ~ in %%~a removes the surrounding double quotes.
This example takes the first row of the list. Virtual or disconnected adapters can come first, so use getmac /v to check adapter names when you need to be sure.
Summary
| Goal | Command |
|---|---|
| Check MAC addresses | getmac |
| Show adapter names too | getmac /v |
| Output as CSV | getmac /fo csv |
| Omit the header | getmac /fo csv /nh |
| Check another PC | getmac /s computer |