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 Enforce Password
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 Install Homebrew
67 Remove VPN icon
68 Fetch the Apple ID of each user account
69 Manage Wi-Fi settings
70 Launch apps automatically on device startup
71 Check if Find My Mac is enabled
72 Distribute security certificates
73 Install Rosetta 2
74 Find code requirements of an app
75 Configure homepage for Safari browser
76 Create ZIP file
77 List App Store apps
78 Wipe and reinstall macOS
79 Add Secure token
80 Modify system language
81 Create disk image
82 Set battery charge limit
83 Change app language
84 Change file or folder permissions
85 Clear all cache files
86 Modify Finder Preferences
87 Encrypt/Decrypt file
88 Fetch location of Mac using IP address
89 Remove badge notifications
90 Fetch kernel extensions
91 Fetch network details
92 Enable/disable location services
93 Fetch running processes
94 Force enable/disable FileVault
  • Sample Script Repository