Skip to content

Instantly share code, notes, and snippets.

@4np
Created June 29, 2026 13:12
Show Gist options
  • Select an option

  • Save 4np/83ea790132d54acbfe8845542e67e615 to your computer and use it in GitHub Desktop.

Select an option

Save 4np/83ea790132d54acbfe8845542e67e615 to your computer and use it in GitHub Desktop.
Stay part of the macOS / Active Directory admin group.
# Add this cronjob for root (e.g. see sudo crontab -l) and replace user.name with the actual username
# of the user that should retain admin membership). Whenever the admin membership is revoked the the
# user, this cronjob will re-add the user to the admin group.
#
# This runs every second; tweak the trigger moment if needed.
* * * * * dscl . -read /Groups/admin GroupMembership|grep -vq "user.name" && dscl . -merge /Groups/admin GroupMembership "user.name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment