Getting MAC address from physical adapters

Created by Izzat Amirul, Modified on Tue, 29 Nov 2022 at 03:41 PM by Izzat Amirul

Command
  1. wmic nic WHERE "PNPDeviceID LIKE '%PCI%' AND ProductName LIKE '%Wi%'" GET MacAddress | findstr /C:":"
Command Anatomy
  1. wmic - Windows CLI legacy tool for accessing WMI data
  2. nic - The alias of the WMI class we are querying
  3. WHERE
  4. PNPDeviceID LIKE '%PCI%' - Find results from the PNPDeviceID column that has the string 'PCI' anywhere in the string. Determines if device is a physical PCI device.
  5. AND
  6. ProductName LIKE '%Wi%' - Find results from the ProductName column that has the string 'Wi' anywhere in the string. Determines if device is a wireless adapter.
  7. GET
  8. MacAddress - The column we want results from
  9. |
  10. findstr - The find string command. WMIC returns results with headers and we are doing this to get only the MAC address without the header so we can directly return the result to the VSA agent procedure through #global:cmdresults#
  11. /C:":" - Specifying the pattern to the findstr command. ":" tells findstr to look for a colon.
Limitations
  1. Doesn't cater to USB devices
  2. Can break the agent procedure for machines with multiple physical devices (eg. Dual LAN)

Was this article helpful?

That’s Great!

Thank you for your feedback

Sorry! We couldn't be helpful

Thank you for your feedback

Let us know how can we improve this article!

Select atleast one of the reasons

Feedback sent

We appreciate your effort and will try to fix the article