Guest User

Untitled

a guest
Nov 18th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #!/bin/bash
  2. # checkUsersWithoutSecureToken.sh
  3. #
  4. # Purpose: Determines which users do not have a Secure Token on High Sierra
  5. # This tells us which users will not be able to add other users via sysadminctl.
  6. #
  7. # Written by: Patrick Gallagher
  8.  
  9. OSvers=$( sw_vers -productVersion | cut -d. -f2 )
  10.  
  11. if [[ "$OSvers" -le 12 ]]; then
  12. echo "<result>N/A</result>"
  13. exit 0
  14. fi
  15.  
  16. except=('casperadmin' 'mfe')
  17. list=()
  18.  
  19. # generate user list of users that do have not have a secure token
  20. for username in $(dscl . list /Users UniqueID | awk '$2 > 500 { print $1 }'); do
  21. TestAdminToken=$( (sysadminctl -secureTokenStatus "$username") 2>&1)
  22. if [[ "$TestAdminToken" != *ENABLED* ]] &&
  23. grep -qvFf <(printf '%s\n' "${except[@]}") <(echo "$username")
  24. then
  25. # Any reported accounts are added to the array list
  26. list+=("$username")
  27. fi
  28. done
  29.  
  30. # Prints the array's list contents
  31. echo "<result>${list[*]}</result>"
Add Comment
Please, Sign In to add comment