Mac scripting
Scripting is a way to automate the execution of certain routine or time-consuming tasks on Macs. The scripts can be deployed to devices with a device management solution, and together with the solution's automation possibilities, administrators gain more management options over the organization's Macs. This article explains how you can manage and deploy scripts for your macOS devices with GoTo Resolve MDM.
Requirements
- Feature is available for Macs running macOS Catalina (version 10.15) or above.
Additional information
Mac scripting requires that the GoTo Resolve MDM Client app (process name "GoTo Resolve MDM client") has been installed on a macOS device. This lightweight application will be automatically installed on all Macs (version 10.15 or above) that are enrolled in your GoTo Resolve MDM site.
How to add macOS scripts to GoTo Resolve MDM
Start adding a script to GoTo Resolve MDM as a macOS application from the Applications page ( ).
The layout of the screen may look different in the product.
After you have selected the type: Script, you can enter the details of the script.
The layout of the screen may look different in the product.
Description - This field can be used to identify the application and its different deployment methods. This information is available on the Items tab of the Business policy, and on the Application version as a part of the field Deployment methods.
Application name - The application name is also visible to the device user.
Script - The script that will be executed on the macOS device. You may write the script straight to the text field or copy it there from a file.
Success return codes - The return code(s) or a range of return codes for successful execution. Separate the codes by comma, for example, 0,100,200-204. If the field is left empty, the defaul code for successful execution is 0.
Required free disk space (MB) - Defines the required free disk space in megabytes.
About the script
A shell script should start with the character sequence #! (shebang) followed by the interpreter to used to execute the script. For example, #!/bin/bash would run a bash script. For more information, please refer to Apple's documentation or Scripting OS X blog post.
There are multiple different programs for writing a script. You may compose scripts with a plain text editor, but there are also third-party solutions that can make the scripting easier with the features like syntax highlighting, autocompletion, and code formatting.
Viewing and editing a script
You can view and edit the script on the Application version page. Go to the Applications list (
) and choose the application. From the Application page, select the version.The layout of the screen may look different in the product.
On the Application version page, there are three tabs:
- Deployment methods - You can view and edit the script details.
- Deployments - You can see the deployment history of the script.
- Devices - You can see the details of the devices the script is deployed to.
The layout of the screen may look different in the product.
Script deployment
We highly recommend you first test the script locally before deploying it in bulk. You can deploy the created script from
- the Applications list ( ),
- the Application version page ( ),
- the Devices list ( ),
- the Device page ( ).
The layout of the screen may look different in the product.
Automating the deployment with Business policy
You might want to automate the script deployment process with the Business policies. When you create and enable a policy, it will be enforced on all devices within the scope. From the Deployments tab on the Device page ( ), you may see if a device is compliant with the policy.
The layout of the screen may look different in the product.
Monitoring and troubleshooting
On the Application version page (
), there the Deployments tab that shows the details of when and on which devices the script has been deployed.The layout of the screen may look different in the product.
You may also view the deployment status of a single device from the Device page.
The layout of the screen may look different in the product.
The Applications -table shows the deployed applications, also scripts. The briefcase is a sign of Business policy-driven application. With the trashcan, you can remove the application from the table and uninstall other applications except for scripts from the device. It is good to note that when the device is in the scope of a Business policy, which includes the removed script, the policy will deploy the script again to the device.
In case there are problems with the script install, you can try to investigate the reason for the failure from the Action log (
) or the Action log tab of the specific device ( ). Hover the mouse cursor over the red Failed text of the row in the Action log, and you will see an error message that might troubleshoot the problem.One reason for the failure might be, for example, that the device is rebooted or switched off during the deployment. It is also good to check the correctness of the script, that it is including all the needed syntaxes, etc.