Category filter

Script to check if a user is an Administrator on Mac

A macOS device may have multiple user accounts with administrator privileges. You can list these accounts with admin access and remotely check if a particular user has admin access by executing scripts using Hexnode’s Execute Custom Script action.

Scripting Language- Bash

File extension- .sh


The Sample Scripts provided below are adapted from third-party Open-Source sites.

Check if a user is admin or not

The command returns “is admin” or “not admin” based on the username provided. Pass the username of the account to the device by replacing username in the script.

groups: shows all username groups

grep –q –w admin: Searches for username user in the ‘admin’ group

Fetch a list of admin users

The command reads and lists all users with admin privileges.


  • It is recommended to manually validate the script execution on a system before executing the action in bulk.
  • Hexnode will not be responsible for any damage/loss to the system on the behavior of the script.

  • Sample Script Repository