# Mac Shell Scripting Resources

With Hexnode UEM, you may [remotely execute scripts](https://www.hexnode.com/mobile-device-management/help/how-to-run-scripts-on-mac-using-hexnode-mdm/) 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.

 Notes: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
------------

Sample script

echo argument

   1

  echo argument

   

 

  

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](https://www.hexnode.com/mobile-device-management/help/wp-content/uploads/2021/07/script_show-output.png)

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](https://cdn.hexnode.com/mobile-device-management/help/wp-content/uploads/2021/07/Screen-Shot-2021-06-30-at-6.21.37-PM.png)

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](https://www.hexnode.com/mobile-device-management/help/execute-custom-scripts-to-set-data-and-time-for-macos-devices/)2[Set time zone](https://www.hexnode.com/mobile-device-management/help/script-to-set-time-zone-for-mac/)3[Set up Cisco Umbrella Roaming Client](https://www.hexnode.com/mobile-device-management/help/script-to-set-up-cisco-umbrella-roaming-client-on-mac/)4[Shutdown Mac](https://www.hexnode.com/mobile-device-management/help/script-to-shutdown-mac/)5[Configure Sleep settings](https://www.hexnode.com/mobile-device-management/help/script-to-configure-sleep-settings-for-mac/)6[Open apps](https://www.hexnode.com/mobile-device-management/help/script-to-open-apps-on-mac/)7[Close apps](https://www.hexnode.com/mobile-device-management/help/script-to-force-close-apps-on-mac/)8[Uninstall apps](https://www.hexnode.com/mobile-device-management/help/script-to-uninstall-apps-on-mac/)9[Create files and folders](https://www.hexnode.com/mobile-device-management/help/script-to-create-files-and-folders-for-mac/)10[Open files and folders](https://www.hexnode.com/mobile-device-management/help/script-to-open-files-and-folders-on-mac/)11[Copy files and folders](https://www.hexnode.com/mobile-device-management/help/script-to-copy-files-and-folders-on-mac/)12[Move files and folders](https://www.hexnode.com/mobile-device-management/help/script-to-move-files-and-folders-on-mac/)13[Delete files and folders](https://www.hexnode.com/mobile-device-management/help/script-to-delete-files-and-folders-on-mac/)14[Create new users](https://www.hexnode.com/mobile-device-management/help/script-to-create-new-users-on-mac/)15[Fetch user details](https://www.hexnode.com/mobile-device-management/help/script-to-fetch-user-details-on-mac/)16[Change user password](https://www.hexnode.com/mobile-device-management/help/script-to-change-user-password-on-mac/)17[Enable/Disable Firewall](https://www.hexnode.com/mobile-device-management/help/script-to-enable-disable-firewall-in-macos-devices/)18[Update OS](https://www.hexnode.com/mobile-device-management/help/script-to-update-os-in-macos-devices/)19[Copy text to clipboard](https://www.hexnode.com/mobile-device-management/help/script-to-copy-a-text-to-clipboard-of-macos-devices/)20[Set Wallpaper](https://www.hexnode.com/mobile-device-management/help/script-to-set-desktop-wallpaper-for-mac/)21[Rename Device](https://www.hexnode.com/mobile-device-management/help/script-to-rename-mac/)22[Check Encryption status](https://www.hexnode.com/mobile-device-management/help/script-to-check-encryption-status-on-mac/)23[Revoke/Give Admin rights to Standard User](https://www.hexnode.com/mobile-device-management/help/script-to-revoke-give-admin-rights-to-standard-user-in-mac/)24[Turn Off Wi-Fi](https://www.hexnode.com/mobile-device-management/help/script-to-turn-off-wi-fi-on-macos-devices/)25[Install Font](https://www.hexnode.com/mobile-device-management/help/script-to-install-font-in-macos-devices/)26[View Login History](https://www.hexnode.com/mobile-device-management/help/script-to-view-login-history-in-macos-devices/)27[Bluetooth Control](https://www.hexnode.com/mobile-device-management/help/script-for-bluetooth-control-in-macos-devices/)28[Set Proxy](https://www.hexnode.com/mobile-device-management/help/script-to-set-proxy-on-mac/)29[Clear Password](https://www.hexnode.com/mobile-device-management/help/script-to-clear-password-on-mac/)30[Enable Password for Screen Lock](https://www.hexnode.com/mobile-device-management/help/script-to-enable-password-for-screen-lock-on-mac/)31[Configure Wi-Fi](https://www.hexnode.com/mobile-device-management/help/script-to-configure-wi-fi-on-mac/)32[Check code signature of an app](https://www.hexnode.com/mobile-device-management/help/script-to-check-the-code-signature-of-an-app-installed-on-mac/)33[Hide Profiles pane from System Preferences](https://www.hexnode.com/mobile-device-management/help/script-to-hide-profiles-pane-from-system-preferences-on-macos-devices/)34[Activate Remote Ring](https://www.hexnode.com/mobile-device-management/help/script-to-activate-remote-ring-on-mac/)35[Delete User Account](https://www.hexnode.com/mobile-device-management/help/script-to-delete-user-account-on-mac/)36[Change Screen Brightness](https://www.hexnode.com/mobile-device-management/help/script-to-change-screen-brightness-on-mac/)37[Fetch Google Chrome Extensions](https://www.hexnode.com/mobile-device-management/help/script-to-fetch-the-google-chrome-extensions-installed-on-mac/)38[Turn on/off Auto Updates in App Store](https://www.hexnode.com/mobile-device-management/help/script-to-turn-on-off-auto-updates-in-app-store-for-mac/)39[Customize Login Window](https://www.hexnode.com/mobile-device-management/help/script-to-customize-login-window-on-mac/)40[Enable/Disable AirDrop](https://www.hexnode.com/mobile-device-management/help/script-to-enable-disable-airdrop-on-mac/)41[Create User Accounts](https://www.hexnode.com/mobile-device-management/help/script-to-remotely-create-user-accounts-on-macos-devices/)42[Find File/Folder Size](https://www.hexnode.com/mobile-device-management/help/script-to-find-file-or-folder-size-on-mac/)43[Change Ownership of File/Folder](https://www.hexnode.com/mobile-device-management/help/script-to-change-ownership-of-a-file-or-folder-on-mac/)44[List all files in a folder](https://www.hexnode.com/mobile-device-management/help/script-to-list-all-files-in-a-folder-on-mac/)45[Find file path](https://www.hexnode.com/mobile-device-management/help/script-to-find-file-path-on-mac/)46[Erase free space](https://www.hexnode.com/mobile-device-management/help/script-to-erase-free-space-on-mac/)47[Enable Guest User Account](https://www.hexnode.com/mobile-device-management/help/script-to-enable-guest-user-on-mac/)48[View Battery Status](https://www.hexnode.com/mobile-device-management/help/script-to-view-battery-status-on-macos-devices/)49[Disk Utility operations](https://www.hexnode.com/mobile-device-management/help/script-to-execute-disk-utility-operations-on-mac/)50[Fetch list of apps running in the foreground](https://www.hexnode.com/mobile-device-management/help/script-to-fetch-the-applications-running-in-the-foreground-on-mac/)51[Create Sharing Only User Account](https://www.hexnode.com/mobile-device-management/help/script-to-create-sharing-only-user-account-on-mac/)52[Retrieve System Information](https://www.hexnode.com/mobile-device-management/help/script-to-retrieve-system-information-on-mac/)53[Check Disk Usage](https://www.hexnode.com/mobile-device-management/help/script-to-check-disk-usage-on-macos-devices/)54[Set up Printer](https://www.hexnode.com/mobile-device-management/help/script-to-set-up-printers-on-macos-devices/)55[List Internet-connected Apps and Processes](https://www.hexnode.com/mobile-device-management/help/script-to-list-internet-connected-apps-and-processes-on-mac/)56[Prevent File Modification](https://www.hexnode.com/mobile-device-management/help/script-to-prevent-file-modification-on-mac/)57[Allow/Block Websites](https://www.hexnode.com/mobile-device-management/help/script-to-allow-block-websites-on-mac/)58[Time Machine Backup](https://www.hexnode.com/mobile-device-management/help/script-for-time-machine-backup-in-mac/)59[Schedule Restart](https://www.hexnode.com/mobile-device-management/help/script-to-schedule-restart-on-mac/)60[Hide/Disable different System Preferences panes](https://www.hexnode.com/mobile-device-management/help/script-to-hide-disable-different-system-preferences-panes-on-mac/)61[Disable/Enable Notification Center](https://www.hexnode.com/mobile-device-management/help/script-to-disable-enable-notification-center-on-macos-devices/)62[Customize Dock preferences](https://www.hexnode.com/mobile-device-management/help/script-to-customize-dock-preferences-on-mac/)63[Enable/Disable Remote Management](https://www.hexnode.com/mobile-device-management/help/script-to-enable-remote-management-on-mac/)64[Clear browsing history](https://www.hexnode.com/mobile-device-management/help/script-to-clear-browser-history-on-mac/)65[Check if user is admin ](https://www.hexnode.com/mobile-device-management/help/script-to-check-if-a-user-is-an-administrator-on-mac/)66[Remove VPN icon](https://www.hexnode.com/mobile-device-management/help/script-to-hide-the-vpn-icon-from-the-menu-bar-on-mac/)67[Fetch the Apple ID of each user account ](https://www.hexnode.com/mobile-device-management/help/script-to-fetch-the-apple-ids-of-users-on-mac/)68[Manage Wi-Fi settings](https://www.hexnode.com/mobile-device-management/help/scripts-to-manage-wi-fi-network-settings-on-macos-devices/)69[Launch apps automatically on device startup](https://www.hexnode.com/mobile-device-management/help/script-to-launch-apps-automatically-while-logging-in-to-mac/)70[Check if Find My Mac is enabled](https://www.hexnode.com/mobile-device-management/help/script-to-check-if-find-my-mac-is-enabled-on-mac/)71[Distribute security certificates ](https://www.hexnode.com/mobile-device-management/help/script-to-distribute-certificate-on-macos-devices/)72[Install Rosetta 2](https://www.hexnode.com/mobile-device-management/help/script-to-install-rosetta-2-on-mac-devices-with-apple-silicon/)73[Find code requirements of an app](https://www.hexnode.com/mobile-device-management/help/how-to-find-the-code-requirement-of-an-application-on-mac/)74[Configure homepage for Safari browser](https://www.hexnode.com/mobile-device-management/help/script-to-set-safari-homepage-on-mac/)75[Create ZIP file](https://www.hexnode.com/mobile-device-management/help/script-to-create-password-protected-zip-file-on-macos-devices/)76[List App Store apps](https://www.hexnode.com/mobile-device-management/help/script-to-fetch-a-list-of-apps-installed-from-the-app-store-on-mac/)77[Wipe and reinstall macOS](https://www.hexnode.com/mobile-device-management/help/script-to-wipe-and-reinstall-macos/)78[Add Secure token](https://www.hexnode.com/mobile-device-management/help/script-to-add-secure-token-to-users-on-macos-devices/)79[Modify system language](https://www.hexnode.com/mobile-device-management/help/script-to-change-system-language-on-mac/)80[Create disk image](https://www.hexnode.com/mobile-device-management/help/script-to-create-a-disk-image-from-a-folder-on-macos-devices/)81[Set battery charge limit](https://www.hexnode.com/mobile-device-management/help/script-to-set-charging-limit-on-macos-devices/)82[Change app language](https://www.hexnode.com/mobile-device-management/help/script-to-change-app-language-on-mac/)83[Change file or folder permissions](https://www.hexnode.com/mobile-device-management/help/script-to-change-file-folder-permissions-on-mac/)84[Clear all cache files](https://www.hexnode.com/mobile-device-management/help/script-to-clear-cache-on-macos-devices/)85[Modify Finder Preferences](https://www.hexnode.com/mobile-device-management/help/script-to-customize-finder-preferences-on-mac/)86[Encrypt/Decrypt file](https://www.hexnode.com/mobile-device-management/help/script-to-encrypt-and-decrypt-files-on-a-mac/)87[Fetch location of Mac using IP address](https://www.hexnode.com/mobile-device-management/help/script-to-find-the-location-of-a-mac-using-its-ip-address/)88[Remove badge notifications](https://www.hexnode.com/mobile-device-management/help/script-to-remove-badge-notifications-in-mac/)89[Fetch kernel extensions](https://www.hexnode.com/mobile-device-management/help/script-to-display-kernel-extensions-on-mac/)90[Fetch network details](https://www.hexnode.com/mobile-device-management/help/script-to-get-network-info-on-mac/)91[Enable/disable location services](https://www.hexnode.com/mobile-device-management/help/script-to-enable-disable-location-services-on-macos-devices/)92[Fetch running processes](https://www.hexnode.com/mobile-device-management/help/script-to-manage-running-processes-on-mac/)93[Force enable/disable FileVault](https://www.hexnode.com/mobile-device-management/help/script-to-forcefully-enable-disable-filevault-on-mac/)94[Fetch system or app logs](https://www.hexnode.com/mobile-device-management/help/script-to-fetch-device-logs/)95[Deploy ZIP file](https://www.hexnode.com/mobile-device-management/help/script-to-deploy-zip-file-to-macs-using-a-url/)96[Send custom notifications](https://www.hexnode.com/mobile-device-management/help/script-to-send-notifications-to-a-mac-using-terminal-notifier/)97[Configure trackpad settings](https://www.hexnode.com/mobile-device-management/help/script-to-configure-trackpad-settings-on-macos-devices/)98[Automatic download of OS updates](https://www.hexnode.com/mobile-device-management/help/script-to-disable-automatic-download-of-os-updates-on-mac/)99[Hide/Unhide files and folders](https://www.hexnode.com/mobile-device-management/help/script-to-hide-unhide-files-and-folders-on-macos-devices/)100[Change alert sound and volume](https://www.hexnode.com/mobile-device-management/help/script-to-change-alert-sound-and-volume-settings-on-macos-devices/)101[Change screenshot settings](https://www.hexnode.com/mobile-device-management/help/script-to-change-screenshot-settings-on-mac/)102[Delete files based on size](https://www.hexnode.com/mobile-device-management/help/script-to-delete-files-based-on-size-on-mac/)103[Set screen saver photo slideshow](https://www.hexnode.com/mobile-device-management/help/script-to-set-screen-saver-on-mac/#set-slideshow-screen-saver)104[Empty Trash](https://www.hexnode.com/mobile-device-management/help/script-to-empty-trash-on-mac/)105[Get app path](https://www.hexnode.com/mobile-device-management/help/script-to-get-the-app-path-of-an-application-from-macos-devices/)106[Install unsigned package file](https://www.hexnode.com/mobile-device-management/help/script-to-install-unsigned-packages-on-mac/)107[Install latest Firefox](https://www.hexnode.com/mobile-device-management/help/script-to-install-the-latest-firefox-version-on-macos-devices/)108[Delete mobile accounts](https://www.hexnode.com/mobile-device-management/help/script-to-delete-mobile-accounts-on-mac/)109[Run Setup Assistant on Macs](https://www.hexnode.com/mobile-device-management/help/script-to-run-setup-assistant-on-macs-in-the-next-reboot/)110[Setup policy banner](https://www.hexnode.com/mobile-device-management/help/script-to-setup-a-policy-banner-on-macos-devices/)111[Fetch last opened timestamp of apps/files](https://www.hexnode.com/mobile-device-management/help/script-to-view-the-last-opened-time-of-apps-files-on-macos/)112[Show Bluetooth status in menu bar](https://www.hexnode.com/mobile-device-management/help/script-to-show-bluetooth-menu-on-status-bar-of-macos-devices/)113[Get versions of installed apps](https://www.hexnode.com/mobile-device-management/help/script-to-get-versions-of-installed-apps-on-macos/)114[Reduce motion and transparency](https://www.hexnode.com/mobile-device-management/help/script-to-reduce-motion-and-transparency-on-macos-devices/)115[Keyboard settings](https://www.hexnode.com/mobile-device-management/help/script-to-configure-keyboard-settings-on-mac/)116[Manage Spotlight Indexing](https://www.hexnode.com/mobile-device-management/help/script-to-manage-spotlight-indexing-on-macos-devices/)117[Check if a user exists](https://www.hexnode.com/mobile-device-management/help/script-to-check-if-a-user-exists-on-macos-devices/)118[Show/Hide Screen Mirroring status on the menu bar](https://www.hexnode.com/mobile-device-management/help/script-to-show-hide-screen-mirroring-icon-on-the-menu-bar-on-mac/)