EA to collect ethernet adapter MAC address

dpertschi
Valued Contributor

For JSS 8.x-- Has anyone already developed EA's to collect ethernet adapter MAC addresses?

I'm not convinced all my client and support staff are giving me this information so that I can add them to the removable address list.

1 ACCEPTED SOLUTION

mm2270
Legendary Contributor III

Yeah, we have ones or both. As with anything, there are probably a half dozen ways this can be done, and there may be better ways, but these work for us

USB Ethernet

#!/bin/sh

USBMAC=$(networksetup -listallhardwareports | awk '/Hardware Port: USB Ethernet/{getline; getline; print $NF}')

if [[ "$USBMAC" == "" ]]; then
    echo "<result>N/A</result>"
else
    echo "<result>$USBmac</result>"
fi

Thunderbolt Ethernet

#!/bin/sh

TBMAC=$(networksetup -listallhardwareports | awk '/Hardware Port: Thunderbolt Ethernet/{getline; getline; print $NF}')

if [[ "$TBMAC" == "" ][; then
    echo "<result>N/A</result>"
else
    echo "<result>$TBMAC</result>"
fi

View solution in original post

2 REPLIES 2

mm2270
Legendary Contributor III

Yeah, we have ones or both. As with anything, there are probably a half dozen ways this can be done, and there may be better ways, but these work for us

USB Ethernet

#!/bin/sh

USBMAC=$(networksetup -listallhardwareports | awk '/Hardware Port: USB Ethernet/{getline; getline; print $NF}')

if [[ "$USBMAC" == "" ]]; then
    echo "<result>N/A</result>"
else
    echo "<result>$USBmac</result>"
fi

Thunderbolt Ethernet

#!/bin/sh

TBMAC=$(networksetup -listallhardwareports | awk '/Hardware Port: Thunderbolt Ethernet/{getline; getline; print $NF}')

if [[ "$TBMAC" == "" ][; then
    echo "<result>N/A</result>"
else
    echo "<result>$TBMAC</result>"
fi

djrory
Contributor

Any ideas how to do this on iPad with Belkin LAN + PoE adapter?