Category filter

Script to set time zone for Mac

A macOS device automatically configures the time zone under the Date & Time preferences depending on its current location. However, if you want to specify the time zone of a device over the air, you can get it done with the help of scripts. The
Execute Custom Script
action from Hexnode streamlines this process where you run customized scripts directly from the UEM console.

Scripting language – Bash

File extension – .sh

Disclaimer:

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

Set time zone

Replace $1 with your preferred time zone and deploy the above custom script from the Hexnode UEM console to the device.

Consider the following script. It explicitly sets the device’s time zone to “Pacific/Ponape”:

There is a possibility that your device still shows the incorrect date and time even after setting the time zone. This might be because you have not enabled the Set date and time automatically option on the device. Either enable this option manually on the device or deploy the script given below from the Hexnode console to the device to automatically adjust the time and date.

List time zones

You can obtain a list of time zones from the device by running the following script from the UEM console:

Any of the listed time zones replace the $1 argument of the Set time zone custom script, which can then be deployed from the Hexnode console to the device.

Notes:

  • Enforcing the time zone on a device manually also adjusts the device clock based on the specified location.
  • 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