Posted on 03-13-2023 07:33 PM
I was wondering if we can build a smart group for devices based on the devices country?
at the moment, we have our devices scattered around the globe (USA[Chicago/NewYork/SanFrancisco/Florida/Houston], United Kingdom, South Africa, Japan, New Zealand, Australia [Sydney/Melbourne/Brisbane/Perth]
Solved! Go to Solution.
Posted on 03-14-2023 06:03 AM
JAMF has a built-in Extension Attribute for IP-GEO Location. I had to fix a few fields, but it will report City, State and Two Character Country Code.
#!/bin/sh
myIP=`/usr/bin/curl http://ifconfig.me/ip`
myLocationInfo=`/usr/bin/curl http://ip-api.com/xml/$myIP`
mycountryCode=`echo $myLocationInfo|egrep -o '<countryCode>.*</countryCode>'| sed -e 's/^.*<countryCode/<countryCode/' | cut -f2 -d'>'| cut -f1 -d'<'`
mycity=`echo $myLocationInfo|egrep -o '<city>.*</city>'| sed -e 's/^.*<city/<city/' | cut -f2 -d'>'| cut -f1 -d'<'`
myregionName=`echo $myLocationInfo|egrep -o '<regionName>.*</regionName>'| sed -e 's/^.*<regionName/<regionName/' | cut -f2 -d'>'| cut -f1 -d'<'`
echo "<result>$mycity, $myregionName - $mycountryCode</result>"
Posted on 03-13-2023 11:38 PM
You can build a smart group for devices based on their country in Jamf Pro. You can use the device inventory information, specifically the "Location" field, to create a smart group based on the devices' country.
Here are the steps to create a smart group based on the devices' country in Jamf Pro:
You can repeat these steps to create smart groups for each country where your devices are located. Once you have created the smart groups, you can use them to manage and deploy policies and configurations to devices based on their location.
Posted on 03-14-2023 06:03 AM
JAMF has a built-in Extension Attribute for IP-GEO Location. I had to fix a few fields, but it will report City, State and Two Character Country Code.
#!/bin/sh
myIP=`/usr/bin/curl http://ifconfig.me/ip`
myLocationInfo=`/usr/bin/curl http://ip-api.com/xml/$myIP`
mycountryCode=`echo $myLocationInfo|egrep -o '<countryCode>.*</countryCode>'| sed -e 's/^.*<countryCode/<countryCode/' | cut -f2 -d'>'| cut -f1 -d'<'`
mycity=`echo $myLocationInfo|egrep -o '<city>.*</city>'| sed -e 's/^.*<city/<city/' | cut -f2 -d'>'| cut -f1 -d'<'`
myregionName=`echo $myLocationInfo|egrep -o '<regionName>.*</regionName>'| sed -e 's/^.*<regionName/<regionName/' | cut -f2 -d'>'| cut -f1 -d'<'`
echo "<result>$mycity, $myregionName - $mycountryCode</result>"
Posted on 03-14-2023 02:44 PM
Thank you.
i put this script as my extension attribute and used it to create smartgroup.