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