All MAC Addresses Ext. Attributes

DaneAbernathy
New Contributor III

I searched a few places, here included, and found some good info, but was getting stuck on getting a USB ethernet/hub/dock MAC address since it has so many "/" it was throwing the awk off. They usually show up as "USB 10/100/1000 LAN" and everything I tried just kept returning  "Not Available".

Using some previous posts and scripts, here's what I have now:

 

#!/bin/bash
DEVICE_MAC=$(/usr/sbin/networksetup -listallhardwareports | awk '/USB*LAN/{getline; getline; print $NF}')
if [ ! -z "$DEVICE_MAC" ]; then
    echo "<result>$DEVICE_MAC</result>"
else
    echo "<result>Not Available</result>"
fi

 

 You can replace the "USB*LAN" with "Thunderbolt\ Ethernet" to get any network devices connected via Thunderbolt

 

Hopefully, this helps anyone else who was trying to figure this one out!

 

Edited to add: I know JAMF Pro reports the primary and secondary network MACs. The WiFi is "usually" reported as primary, and then Thunderbolt 1 usually reports as secondary. Which for us was useless. Once you connect a thunderbolt to ethernet adapter it added another network device "Thunderbolt Ethernet" with a different MAC, expected yes lol, so this is how I remedied my problem.

 

This is also working on Thunderbolt 4 devices reporting a MAC for Thunderbolt Ethernet

0 REPLIES 0