Secondary Mac Address - ( How To Export Data ) - Extension Attribute

Hugonaut
Valued Contributor II

Didn't Find a Solution on here so I thought I would share mine that worked flawlessly.

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month
1 ACCEPTED SOLUTION

Hugonaut
Valued Contributor II
THIS NOTE IS ADDED AFTER @bpavlov @mm2270 provided the below insight & comments THIS WORKS FOR OLDER (late 2009 & up) MacBook Pro Models & The 2016 Air Models. Our en1 configured is configured for wifi & en0 is configured for ethernet. en0 being primary & en1 being secondary in our JSS.

Steps

Create an extension attribute with the following script & Wallah (can obvi replace en1 w/ whatever you want from the ifconfig options.
Once configured you can create an Advanced Computer Search and select your secondary mac address extension attribute and export =)

#!/bin/sh
result=`ifconfig en1 | grep ether | awk '{print $2}'`
echo "<result>$result</result>"

c1ad11a41a9742c2a4de86c3bf1ffb79

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

View solution in original post

4 REPLIES 4

Hugonaut
Valued Contributor II
THIS NOTE IS ADDED AFTER @bpavlov @mm2270 provided the below insight & comments THIS WORKS FOR OLDER (late 2009 & up) MacBook Pro Models & The 2016 Air Models. Our en1 configured is configured for wifi & en0 is configured for ethernet. en0 being primary & en1 being secondary in our JSS.

Steps

Create an extension attribute with the following script & Wallah (can obvi replace en1 w/ whatever you want from the ifconfig options.
Once configured you can create an Advanced Computer Search and select your secondary mac address extension attribute and export =)

#!/bin/sh
result=`ifconfig en1 | grep ether | awk '{print $2}'`
echo "<result>$result</result>"

c1ad11a41a9742c2a4de86c3bf1ffb79

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month

bpavlov
Honored Contributor

This assumes that en1 will be consistently the same interface you expect. Just be aware of that.

mm2270
Legendary Contributor III

I don't know if hardcoding en1 or any other port id is necessarily a good idea. With some older models only having a built in Ethernet and some not having one at all, it might be better to get whatever the second "en" port is in the list and using that. Generally speaking, en0 will be Wi-Fi on most newer models and en1 would be something like a Thunderbolt connection. On older models, en0 will be Built-In Ethernet and en1 will be something else, but most times, you want the second en port since en0 is what Jamf uses for the "MAC Address" criteria.

#!/bin/bash

PORT=$(networksetup -listallhardwareports | awk '/Device: en/{print $NF}' | sort | sed -n 2p)

if [ ! -z "$PORT" ]; then
    MACADD=$(ifconfig "$PORT" | awk '/ether/{print $2}' | tr '[a-z]' '[A-Z]')
else
    MACADD=$(ifconfig en0 | awk '/ether/{print $2}' | tr '[a-z]' '[A-Z]')
fi

echo "<result>$MACADD</result>"

Hugonaut
Valued Contributor II

Thank you for the insight & responses, updated my original post with what machines we are using and what this works on.

@bpavlov @mm2270

________________
Looking for a Jamf Managed Service Provider? Look no further than Rocketman
________________


Virtual MacAdmins Monthly Meetup - First Friday, Every Month