Skip to content

Instantly share code, notes, and snippets.

@smashism
Created November 30, 2016 18:56
Show Gist options
  • Save smashism/e7326a336aa27566de7e5b440fe7bd85 to your computer and use it in GitHub Desktop.
Save smashism/e7326a336aa27566de7e5b440fe7bd85 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# NoMAD_LastPasswordExpireDate
# Checks NoMAD plist for LastPasswordExpireDate (AD password expiration)
# By github.com/smashism
# Last modified 2016-11-30
# Provided as-is with no support or warranty
loggedInUser=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
LastPasswordExpireDate=$(defaults read "/Users/$loggedInUser/Library/Preferences/com.trusourcelabs.nomad.plist" LastPasswordExpireDate)
if [ "$LastPasswordExpireDate" ]; then
echo "<result>$LastPasswordExpireDate</result>"
else
echo "<result>NoMAD not installed.</result>"
fi
@charliwest
Copy link

Better to use /usr/bin/python it failed for me without it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment