Category Filter

Mac Shell Scripting Resources

With Hexnode UEM, you may remotely execute scripts on devices running macOS 10.11 and above. This document equips you with a collection of shell scripts that Mac admins may find useful in their workflows.


To execute custom script on a Mac with Hexnode UEM, you need a script file which can be of the following formats –

Perl (.pl), Bash (.sh), Shell (.sh), C Shell (.csh), Zsh (.zsh), Korn Shell (.ksh), Hypertext Preprocessor (.php), Ruby (.rb), and Python (.py).

For this document, we are using Bash, and the script file should be saved with the extension .sh.

Once you’ve prepared the script, navigate to Manage > Devices > [Find your device], select Actions > Execute Custom Script; this will open a window for you to upload the script file, enter the binary path to run on and the script arguments. Confirm to execute the script.

To view the script output for a device, go to the Action History sub-tab on the device details page and click on Show Output for the script action.

Echo command

The echo command writes arguments to the standard output. When you manually run the script on the Mac Terminal, this will display the output on the Terminal window. When you run the script remotely on the device with Hexnode, you can see the output with the Show Output link under Action History on the device page.

Click on Show output to view echo output

The argument here can be passed as a string –

echo Hello

Or as an argument or wildcard.

Hexnode supports the following wildcards –

  • %devicename%
  • %deviceid%
  • %wifimacaddress%
  • %name%
  • %domain%
  • %email%
  • %imei%
  • %username%
  • %department%
  • %assettag%
  • %devicenotes%

To use wildcards, pass the wildcards as arguments separated by a blank space.

use a single space to separate your arguments

The wildcard will be automatically included in the code as an argument.

Example – echo $1, $2 becomes echo devicename, name

Sample Scripts

Serial No Script
1 Set date and time
2 Set time zone
3 Set up Cisco Umbrella Roaming Client
4 Shutdown Mac
5 Configure Sleep settings
6 Open apps
7 Close apps
8 Uninstall apps
9 Create files and folders
10 Open files and folders
11 Copy files and folders
12 Move files and folders
13 Delete files and folders
14 Create new users
15 Fetch user details
16 Change user password
17 Enable/Disable Firewall
18 Update OS
19 Copy text to clipboard
20 Set Wallpaper