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
21 Rename Device
22 Check Encryption status
23 Revoke/Give Admin rights to Standard User
24 Turn Off Wi-Fi
25 Install Font
26 View Login History
27 Bluetooth Control
28 Set Proxy
29 Clear Password
30 Enable Password for Screen Lock
31 Configure Wi-Fi
32 Check code signature of an app
33 Hide Profiles pane from System Preferences
34 Activate Remote Ring
35 Delete User Account
36 Change Screen Brightness
37 Fetch Google Chrome Extensions
38 Turn on/off Auto Updates in App Store
39 Customize Login Window
40 Enable/Disable AirDrop
41 Create User Accounts
42 Find File/Folder Size
43 Change Ownership of File/Folder
44 List all files in a folder
45 Find file path
46 Erase free space
47 Enable Guest User Account
48 View Battery Status
49 Disk Utility operations
50 Fetch list of apps running in the foreground
51 Create Sharing Only User Account
52 Retrieve System Information
53 Check Disk Usage
54 Set up Printer
55 List Internet-connected Apps and Processes
56 Prevent File Modification
57 Allow/Block Websites
58 Time Machine Backup
59 Schedule Restart
60 Hide/Disable different System Preferences panes
61 Disable/Enable Notification Center
62 Customize Dock preferences
63 Enable/Disable Remote Management
64 Clear browsing history
65 Check if user is admin
66 Remove VPN icon
67 Fetch the Apple ID of each user account
68 Manage Wi-Fi settings
69 Launch apps automatically on device startup
70 Check if Find My Mac is enabled
71 Distribute security certificates
72 Install Rosetta 2
73 Find code requirements of an app
74 Configure homepage for Safari browser
75 Create ZIP file
76 List App Store apps
77 Wipe and reinstall macOS
78 Add Secure token
79 Modify system language
80 Create disk image
81 Set battery charge limit
82 Change app language
83 Change file or folder permissions
84 Clear all cache files
85 Modify Finder Preferences
86 Encrypt/Decrypt file
87 Fetch location of Mac using IP address
88 Remove badge notifications
89 Fetch kernel extensions
90 Fetch network details
91 Enable/disable location services
92 Fetch running processes
93 Force enable/disable FileVault
94 Fetch system or app logs
95 Deploy ZIP file
96 Send custom notifications
97 Configure trackpad settings
98 Automatic download of OS updates
99 Hide/Unhide files and folders
100 Change alert sound and volume
101 Change screenshot settings
102 Delete files based on size
103 Set screen saver photo slideshow
104 Empty Trash
105 Get app path
106 Install unsigned package file
107 Install latest Firefox
108 Delete mobile accounts
109 Run Setup Assistant on Macs
110 Setup policy banner
111 Fetch last opened timestamp of apps/files
112 Show Bluetooth status in menu bar
  • Sample Script Repository