Tip of the Week: Getting the MAC address on Windows

Blog Post created by ken_foster on Nov 29, 2014

Most of you reading this already know that opening a DOS command shell and entering the command 'ipconfig /all' will return a lot of useful information, including the MAC address. If you use the MAC address as the hostid for mobile compute licenses you have done this many times I suspect. Nothing wrong with doing that, it works. But if you'd like a way of doing it that returns a lot less data you don't need, can be executed remotely, and could be used to obtain this information programmatically for your entire user base- read on.


Such a command exists, and it's been there the whole time: getmac


getmac has some useful options which you can read about by running the command 'getmac /?'. Here are the ones I find most useful:


This one returns the MAC address for each network device without any header information.

C:\> getmac /nh

00-26-B9-xx-xx-xx   \Device\Tcpip_{66A49F71-AB71-42BE-99D0-71027A377490}

00-50-56-C0-00-01   \Device\Tcpip_{9A9C7A14-6867-4877-8DFD-E1DA5378ADDF}

00-50-56-C0-00-08   \Device\Tcpip_{7CABA731-102F-4BB1-A4DA-D054804F6E31}


It is easy to identify my wired device in this case, because I know anything that has 00-50-56-C0 at the beginning is a VMware virtual adapter. But let's pretend I had a wireless adapter in my machine also, and I got 2 addresses that were not virtual adapters. How would I know which of them was the one I wanted?


I'd use the /v (verbose) option:


C:\> getmac /nh /v

Local Area Conn Broadcom NetXtr 00-26-B9-xx-xx-xx   \Device\Tcpip_{66A49F71-AB71-42BE-99D0-71027A377490}

VMware Network  VMware Virtual  00-50-56-C0-00-01   \Device\Tcpip_{9A9C7A14-6867-4877-8DFD-E1DA5378ADDF}

VMware Network  VMware Virtual  00-50-56-C0-00-08   \Device\Tcpip_{7CABA731-102F-4BB1-A4DA-D054804F6E31}


If I'd had another hardware NIC, I could tell by the description which was which.


So far, all the information has come from my local machine. If I want to know the MAC addresses on a different machine, I'll use the /s option:


C:\>getmac /s orw-kfost-t5610


Physical Address    Transport Name

=================== ==========================================================

34-17-EB-xx-xx-xx   \Device\Tcpip_{EC36C646-EB29-4E80-92AC-3D3F91293B22}

00-50-56-C0-00-01   \Device\Tcpip_{9D1AE766-04FB-4E67-BE2E-FD6A64BDF54A}

00-50-56-C0-00-08   \Device\Tcpip_{E3C15C4F-DE49-4E01-8EA1-928704365A9A}


Note that this time I omitted the /nh option so I could see the header.


With a little elbow grease, you could wrap a script around getmac to gather the MAC addresses for your entire site in one go, and then parse that data into a useful report you can use for license ordering or renewal.


Thanks for reading!