Input variables

About input variables

One of the facets of the Datto RMM scripting engine is the ability to use input variables in your scripts. This lets you re-use a single component to carry out multiple tasks without having to modify the script itself, or create (and maintain) duplicate components.

Input variables allow you to define values in your script at runtime, rather than having them hard coded into the script.

EXAMPLE  For example, if you regularly had to restart a number of Windows services (netlogon service, DNS client service, DHCP client service), you could create a separate component for each service. They would be identical, except for the name of the service that was being restarted.
If you used a variable ("servicename") instead, you would need to create only one component (called "Restart Service"). The script would prompt you for the name of the service to be restarted.

How do input variables work in Datto RMM?

Input variables in Datto RMM are a two-step process:

  1. First, the Administrator writing the script must refer to the input variable as if it were any other variable set within the script itself. One might, for example, check to see if the variable in question is "true" or "false" and then act upon it, without defining the variable itself at any point within the code. The name, default value, and type (string, Boolean, etc.) are defined as part of the component and saved as part of the metadata.
  2. When the component is run as part of a job, the user running the component is prompted to input the value they wish the input variable to reflect, which affects how the script runs. These variables are set as environment variables within the endpoint's script interpreter and are treated as if they had been defined as part of the script.

IMPORTANT  If a third party opens a script containing input variables, the input variable will be visible and not the value hidden behind it (these are defined at runtime). Input variables are a great way to obscure information if you suspect someone might inspect the script files on a local system.

How to...