how to build a smartgroup based on the device country

KittyGoyenk
New Contributor III

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]

1 ACCEPTED SOLUTION

daniel_behan
Contributor III

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>"

View solution in original post

3 REPLIES 3

Jaykrishna1
Contributor II

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:

  1. Log in to your Jamf Pro instance.
  2. Click on "Devices" from the left-hand navigation menu.
  3. Click on "Smart Groups" from the top navigation menu.
  4. Click on "New" to create a new smart group.
  5. Give your smart group a name, such as "Devices by Country".
  6. Under the "Criteria" section, click on the "Add Criteria" button and select "Location".
  7. Set the "Location" criteria to "contains" and type in the country name (e.g., "United States").
  8. Click on "Save" to create the smart group.

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.

daniel_behan
Contributor III

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>"

Thank you.

i put this script as my extension attribute and used it to create smartgroup.