Category filter

Script to enable Guest User on Mac

The Guest User feature on macOS provides a convenient and secure way for individuals to use a shared or publicly accessible device without a personal account. Though it allows individuals to access the device without authentication, it ensures that they do not access private data and the digital workspace of an existing user account. In an IT organization, enabling guest accounts on Mac computers provides a secure and temporary access solution, allowing individuals to use the system without compromising sensitive company data contained on the device.

The guest user may access shared folders on a Mac without logging in with a password. They may use apps like Safari but are limited from other functionalities like accessing the encrypted disk or creating files (if FileVault is turned on). Also, the guest user cannot change the user or computer settings. Any files they create are stored in a temporary folder that is deleted upon guest log-out. With Hexnode UEM, you can remotely enable the Guest User option by executing a simple Bash command using the Execute Custom Script action.

Scripting language – Bash

File extension – .sh


The sample scripts provided below are adapted from third-party open-source sites.

Enable Guest User Account

  • The defaults command allows you to view and modify the settings used by applications and macOS.
  • The write command is used to write values to property list files.
  • /Library/Preferences/ is the path to the property list file for login window preferences.
  • GuestEnabled is the specific preference key being modified here which controls whether the Guest User account is enabled or disabled.
  • The GuestEnabled key in /Library/Preferences/ accepts a Boolean value.
  • To turn off the Guest User option, replace TRUE with FALSE.

What happens at the device end?

The status under Guest User will change from ‘Off’ to ‘Login only’ in the Users & Groups preferences after the script is executed. To switch to the login screen, click on the Apple icon and select ‘Logout’ from the menu. Once logged out, you’ll see options to log in with your user account and as a Guest User. Select the Guest User option to access the Mac as a guest.

The Guest User status will change from 'Off' to 'Login only' in the Users & Groups preferences


  • The above Bash script works only on macOS devices where Guest User account is already configured.
  • 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