Skip to content
Menu

Unapproved Administrators on This Mac

Lists the members of a Mac's admin group and alerts on names outside a configured allow list or a count over your limit. Root and system accounts are never flagged.

Unapproved administrators on this Mac is free for members.

Enter your email to create your free account and get the file.

We'll email you the script and the weekly MSP Outpost email. Unsubscribe anytime. Privacy policy.

Already a member? Sign in.

Be the first to review Unapproved administrators on this Mac. Tell other MSPs how it worked for you.

Write a Review

LanguageBash
Runs onmacOS 13+; runs as root or a user
Needsbash 3.2, dscl
Read-onlyReads, changes nothing

What It Does

The script lists the members of the local admin group with dscl and alerts when ALLOWED_ADMINS is set and an admin account is not on it, or when there are more admin accounts than MAX_ADMINS. Account names are compared ignoring case, and entries are plain short names with no wildcards.

The root account and system accounts, with a user ID below 500 such as _mbsetupuser on a fresh Mac, are shown but never counted or flagged. Each row shows the account, its user ID, whether it is the signed-in console user, and whether it is hidden. Admin rights that come only from a nested group are not listed.

It changes nothing. Pair it with remove-mac-local-admin-members, which demotes the unapproved accounts once you have read this report.

Before You Run It

  • If you set ALLOWED_ADMINS, include your management admin if it is a counted account.
  • Leave ALLOWED_ADMINS empty to alert only on the count. With no list there is no name check.
  • Set MAX_ADMINS to what your standard is. It counts every admin except root and system accounts.
  • Read the first run as a report before you alert on it.

Type and Risk

  • Type: Monitor. It checks one condition. It exits 1 when it finds the problem, so your RMM can alert on it, 0 when all is well, and 2 when it could not run.
  • Risk: Low. It reads and changes nothing.
  • Restart: It never restarts the machine.
  • Typical run: Under 5 seconds.
  • Example answer: "1 of 3 admin account(s) not approved: jsmith"
  • Tested before listing on macOS 27 (Apple silicon VM) with /bin/bash 3.2, run as root, against its own test cases.

Inputs

Pass an input as an argument (--input-name value), as an environment variable named as listed, which is how most RMMs pass script variables, or change its default in the DEFAULT_ lines near the top of the script. An argument wins over an environment variable, which wins over the default.

  • ALLOWED_ADMINS: Account short names allowed to be admins, comma-separated, e.g. "msp-admin, jsmith". Default empty: no name check.
  • MAX_ADMINS: Alert when there are more than N admin accounts (root not counted). 0 = no limit. Default 2.

Every script also takes DRY_RUN, OUTPUT_FORMAT (Text, Answer, Json or Csv), EXPORT_PATH and RESULT_FIELD, which writes the answer to an RMM custom field, unless the list above words one differently.

License

Provided "as is" under the MIT License, without warranty of any kind. Test before production use. MSP Outpost and User First Digital Inc. accept no liability for any damage or loss.

The Script

test-mac-local-admins.sh · 569 lines · 25.1 KB

Free for Members

Create a free account or sign in to read, copy and download this script.

Welcome Back

Sign in to your MSP Outpost account.