Category filter

Script to view Login History in macOS devices

When multiple users work on the same macOS device, it is advisable to record the history of all the users logged in to the device. This could help you in identifying the user who was using the device during a specified time. You can seamlessly fetch the login history of your macOS devices using Hexnode’s Custom Script feature.

Disclaimer:

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

View a brief login history

You will get a brief history of all the users that have logged in to your macOS device in the past few days. It returns the login time and name of the user who has logged into the device.

View a detailed login history

You will get a detailed list of all the users that have logged in to your macOS device in the past few days. It returns the date, the login and logout time of every session, as well as the name of the user who has logged in to the device during each session.

Obtain the last logged in time of a user

If you want to check the last logged-in time of a particular user, you can use the following script.

Ensure you specify the user’s name is intact. Obtain the actual username of a user using the following script:

It list all the users on a given machine.

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.
  • Sample Script Repository