Skip to main content

Jamf Pro computer extension attribute to collect OS language

Issue Description

How to get the primary language of the computer using Jamf?

Troubleshooting Steps

In Jamf Pro, configure a new extension attribute with the following script:

#!/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>"
Did this answer your question?