Example scripts for managing, administerting, and auditing Jamf Pro LAPS accounts.
Use these as models for creating scripts for your own workflows.
| #!/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 ) |
| https://support.apple.com/guide/iphone/iphone-models-compatible-with-ios-18-iphe3fa5df43/ios | |
| https://support.apple.com/guide/ipad/ipad-models-compatible-with-ipados-18-ipad213a25b2/ipados | |
| https://www.apple.com/watchos/watchos-11/ | |
| Published Date: June 10, 2024 | |
| Updated November 1, 2024 | |
| Verification: https://regex101.com/r/0UDJHk/7 | |
| 1) Exact regex — Matches major model identifier numbers based on Jamf's hardware model identifiers list (more accurate): |
| https://www.apple.com/macos/macos-sequoia/ | |
| Published Date: June 10, 2024 | |
| Updated November 8, 2024 | |
| Updated May 28, 2025 | |
| Verification: https://regex101.com/r/bNOMXz/10 | |
| 1) Exact regex — Matches major model identifier numbers based on Apple's knowledge base article (more accurate): | |
| ^(Mac(1[3-6]|BookPro1[5-8]|BookAir(9|10)|Pro7)|iMac(Pro1|(19|2[01]))|Macmini[89]),\d+$ |
| #!/bin/zsh | |
| :<<ABOUT_THIS_SCRIPT | |
| ------------------------------------------------------------------------------- | |
| Written by:William Smith | |
| Technical Enablement Manager | |
| Jamf | |
| bill@talkingmoose.net | |
| https://gist.github.com/talkingmoose/9f4638932df28c4bebde5dd47be1812a |
| #!/bin/zsh | |
| # get public IP address | |
| publicIP=$( /usr/bin/curl http://ifconfig.me/ip \ | |
| --location \ | |
| --silent \ | |
| --max-time 10 ) | |
| # get GeoIP data | |
| locationData=$( /usr/bin/curl http://ip-api.com/xml/$publicIP \ |
| https://www.apple.com/ios/ios-17-preview/ | |
| https://www.apple.com/ipados/ipados-17-preview/ | |
| Published Date: June 5, 2023 | |
| Verification: https://regex101.com/r/m9HV8T/3 | |
| 1) Exact regex — Matches major model identifier numbers based on Jamf's hardware model identifiers list (more accurate): | |
| ^iPhone1[1-5],\d|iPad([7-9]|1[1-4]),\d+$ |
| https://support.apple.com/en-us/HT213772 | |
| Published Date: March 8, 2024 | |
| Verification: https://regex101.com/r/GCfKMt/11 | |
| 1) Exact regex — Matches major model identifier numbers based on Apple's knowledge base article (more accurate): | |
| ^(Mac(1[345]|BookPro1[5-8]|BookAir([89]|10)|Pro7)|iMac(Pro1|(19|2[01]))|Macmini[89]),\d+$ | |
| 2) Current or higher regex — Matches model identifiers based on Apple's knowledge base article and may match higher versions before this regex is updated (more future-proof). |
| #!/bin/zsh | |
| # get LAPS account username | |
| lapsUsername=$( /usr/libexec/PlistBuddy -c "Print :Users:0:shortName" /var/db/ConfigurationProfiles/Settings/.setupUser ) | |
| # read LAPS account for password information | |
| userPasswordInfo=$( /usr/bin/dscl . read "/Users/$lapsUsername" accountPolicyData | /usr/bin/tail -n +4 ) | |
| # extract Unix epoch date from account password information | |
| passwordChangeDateEpoch=$( /usr/bin/xpath -e '//key[text()="passwordLastSetTime"]/following-sibling::real[1]/text()' 2>/dev/null <<< "$userPasswordInfo" ) |
| #!/bin/zsh | |
| :<<ABOUT_THIS_SCRIPT | |
| ------------------------------------------------------------------------------- | |
| Written by:William Smith | |
| Partner Program Manager | |
| Jamf | |
| bill@talkingmoose.net | |
| https://gist.github.com/talkingmoose/94882adb69403a24794f6b84d4ae9de5 |