Skip to main content

Jamf Pro computer extension attribute to collect OS language

Description

This article provides steps to get the primary language of the computer using Jamf Pro using an extension attribute.

Extension Attribute

In Jamf Pro, create a new scripted extension attribute with the script below:

#!/bin/bash

## Function to get primary language
getPrimaryLanguage() {
launchctl asuser "$loggedInUserID" sudo -u "${loggedInUser}" osascript -l JavaScript \
-e "languages=$.NSUserDefaults.alloc.initWithSuiteName('com.example').objectForKey('AppleLanguages').js" \
-e "languages[0]"
}

## Get logged in user
loggedInUser=$( /usr/bin/stat -f %Su /dev/console )
loggedInUserID=$( /usr/bin/id -u "$loggedInUser" )

## Set primary language variable
primaryLanguage=$( getPrimaryLanguage )

## Print out primary language
echo "Primary macOS Language: $primaryLanguage"
echo "<result>$primaryLanguage</result>"

More Resources

Did this answer your question?