none
Get MAC address of active Ethernet adapter and\or Wireless adapter ONLY RRS feed

  • Question

  • Hi- I've seen a lot of threads about getting network adapter information but none of them seem to fit my scenario...

    I am running a script to capture computer data for an inventory database. Two fields for each record that I need data for are Ethernet MAC and Wireless MAC.

    I am currently using this powershell command:

    $Networks = Get-WmiObject Win32_NetworkAdapterConfiguration -ComputerName $Computer | Where-Object {$_.IPEnabled}

    $MACAddress  = $Networks.MACAddress

    but by what I'm seeing this is grabbing data from the active network adapter, whether it's Ethernet or Wireless. Is this correct?

    If so, how do I resolve this issue? I need to run this script on about 1000 PCs. I've seen threads that say to using some identifying characteristic of the adapter, such as AdapterType of Name but when I've tried these I still get back too much or irrelevant info. And the variations on Name could be in the dozens.

    So what I'm trying to accomplish is to grab the mac of the Ethernet adapter and the mac of the wireless adapter, if present.

    Thanx

    SteveInOregon2017

    "Never, never doubt what nobody is sure about." -Willy Wonka

    • Moved by Bill_Stewart Wednesday, February 14, 2018 7:36 PM Abandoned
    Friday, January 5, 2018 9:02 PM

All replies

  • If you run Get-NetAdapter, it returns "PhysicaMediaType". I've noticed it's kind of hit or miss, but it'll distinguish between BlueTooth, Native 801.11 and 802.3 most of the time. Should get you the data you want. You can select only the connected devices also if needed:

    Get-NetAdapter | Where-Object {$_.MediaConnectionState -like "Connected"} | ft name,InterfaceDescription,PhysicalMediaType,Status -AutoSize


    Jeremy Corbello | https://www.jeremycorbello.com


    • Edited by Jacorbello Friday, January 5, 2018 9:15 PM
    Friday, January 5, 2018 9:15 PM
  • Try:

    Get-NetAdapter |Where{$_.Status -eq 'Up'}|
         select name,macaddress,NdisPhysicalMedium


    \_(ツ)_/

    Friday, January 5, 2018 9:36 PM