Category Filter

Script to Fetch User Details on Mac

Use the below scripts to print details about the users on your Mac. You can also use the script to view the list of all users and fetch information like Unique ID ahead of creating a new user as no two users can share the same Unique ID.

Device admins can remotely run scripts on Macs managed with Hexnode using the Execute Custom Script action.

Scripting Language – Bash

File extension – .sh

Disclaimer:


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

Print list of all users

The Directory Service command-line utility or dscl command can be used to create, read and manage Directory Service data. Since the users on the system are present on the ‘/Users’ directory, we can use the command to fetch the list of all users on the system.

Print list of UniqueIDs assigned to users

Every user on the system has a Unique ID and while creating a new user, device admins might need to know the already allocated Unique IDs in order to assign a fresh ID for the new user.

Notes:

  • 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.