Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save talkingmoose/675ed2a13daab1a00650d144787ba88c to your computer and use it in GitHub Desktop.
Save talkingmoose/675ed2a13daab1a00650d144787ba88c to your computer and use it in GitHub Desktop.
Apple doesn't provide a 1:1 list of devices for iOS, iPadOS, tvOS, watchOS, and visionOS. However, Jamf does maintain a public list for its Jamf Pro servers. This script downloads the listm parses the information, and creates a record of each device followed by its display name.
#!/bin/zsh
# set -x # show command
# trap read debug # require a RETURN after each command
# download mobile device data from Jamf
xml=$( /usr/bin/curl \
--silent \
--url https://hw-model-names.services.jamfcloud.com/1/mobileDeviceModels.xml )
function parseXML {
# parse xml for data
data=$( sed -n "/$1/,/$2/p" <<< "$xml" )
# extract data and concatenate lines
deviceList=$( /usr/bin/awk -F '[<>]' '/model_name/{ model=$3; next } /display_name/{ print model " [" $3 "]" }' <<< "$data" )
# sort the device list from newest to oldest models
/usr/bin/tail -r <<< "$deviceList"
echo
}
# parse xml for Apple Watch data
parseXML "<!-- START iPhone -->" "<!-- END iPhone -->"
parseXML "<!-- START iPad -->" "<!-- END iPad -->"
parseXML "<!-- START iPod -->" "<!-- END iPod -->"
parseXML "<!-- START AppleTV -->" "<!-- END AppleTV -->"
parseXML "<!-- START Vision Pro -->" "<!-- END Vision Pro -->"
parseXML "<!-- START Apple Watch -->" "<!-- END Apple Watch -->"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment