Created
June 2, 2023 20:07
-
-
Save talkingmoose/4c5ffc53ed4aca4d92a81bf83ddea4c9 to your computer and use it in GitHub Desktop.
Reads managed Apple admin account for date and time of last password change and reports in ISO 8601 format.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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" ) | |
# convert Unix epoch date to ISO 8601 standard format | |
passwordChangeDate=$( /bin/date -j -f "%s" "$passwordChangeDateEpoch" +"%F %T" 2>/dev/null ) | |
# report value to Jamf Pro according to computer's local time zone | |
echo "<result>$passwordChangeDate</result>" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment