Extension attribute script for Site wont't work in Big Sur

mucgyver
New Contributor III

Hello all.

Since upgrade to Big Sur, the following EA script seems not to work properly anymore, as it always gives result "Not available". Any idea how to fix this?

#!/bin/sh

apiURL="https://xxx.jamfcloud.com/JSSResource/computers/udid/"
apiUser="xxx"
apiPass="xxx"
MacAdd=$( /usr/sbin/networksetup -getmacaddress en0 | /usr/bin/awk '{ print $3 }' | /usr/bin/sed 's/:/./g' )
udid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID:/ { print $3 }')
siteName=$(/usr/bin/curl -s -u ${apiUser}:${apiPass} "${apiURL}${udid}" | /usr/bin/xpath '/computer/general/site/name[1]/text()' 2>/dev/null)

if [[ $siteName ]]; then
    echo "<result>${siteName}</result>"
else
    echo "<result>Not available</result>"
fi

Thank you and best regards
Christian

1 ACCEPTED SOLUTION

dan-snelson
Valued Contributor II

@mucgyver The following appears to be working for us:

#!/bin/sh
# https://jamfnation.jamfsoftware.com/discussion.html?id=15258#responseChild93856
apiURL="https://jamfpro.company.com/JSSResource/computers/udid/"
apiUser="xxx"
apiPass="xxx"
#MacAdd=$( /usr/sbin/networksetup -getmacaddress en0 | /usr/bin/awk '{ print $3 }' | /usr/bin/sed 's/:/./g' )

udid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID:/ { print $3 }')

siteName=$(/usr/bin/curl -H "Accept: application/xml" -sfku ${apiUser}:${apiPass} "${apiURL}${udid}" | /usr/bin/xmllint --format - | /usr/bin/grep -A3 "<site>" | /usr/bin/awk -F'>|<' '/name/{print $3}')

if [[ $siteName ]]; then
   echo "<result>${siteName}</result>"
else
   echo "<result>Not Available</result>"
fi

exit 0

View solution in original post

2 REPLIES 2

dan-snelson
Valued Contributor II

@mucgyver The following appears to be working for us:

#!/bin/sh
# https://jamfnation.jamfsoftware.com/discussion.html?id=15258#responseChild93856
apiURL="https://jamfpro.company.com/JSSResource/computers/udid/"
apiUser="xxx"
apiPass="xxx"
#MacAdd=$( /usr/sbin/networksetup -getmacaddress en0 | /usr/bin/awk '{ print $3 }' | /usr/bin/sed 's/:/./g' )

udid=$(/usr/sbin/system_profiler SPHardwareDataType | /usr/bin/awk '/Hardware UUID:/ { print $3 }')

siteName=$(/usr/bin/curl -H "Accept: application/xml" -sfku ${apiUser}:${apiPass} "${apiURL}${udid}" | /usr/bin/xmllint --format - | /usr/bin/grep -A3 "<site>" | /usr/bin/awk -F'>|<' '/name/{print $3}')

if [[ $siteName ]]; then
   echo "<result>${siteName}</result>"
else
   echo "<result>Not Available</result>"
fi

exit 0

mucgyver
New Contributor III

@dan-snelson Splendid, thanks. :-)