Command (Execute)

Use the Task Execute Command to run a command on Agents. This allows you to schedule any action that can be performed by a command line. For example, you can use this Task to execute scripts or to automate the export of the results of a Job. See Exporting Job results to XML.


Settings tab

  • In the Command line field, you can:
    • Also refer to a Resource, if necessary. When inserting a Resource link by right-clicking the command line box, the GUID of the selected Resource will be used in the command line. The Resource will be added to the command line box as $Workspace<GUID>, where <GUID> is the unique identifier of the Resource. When the Task is executed, the Resource will be downloaded to the Agent`s cache automatically and will be called from that location.
    • Use the function @[SCRIPT] as a placeholder for the script file. When the Task is executed by an Agent, the function @[SCRIPT] in the command line will be replaced by the path to the script file in the temporary folder on the Agent.
    • Use paths. When using paths in the command line or script, encapsulate them with double quotes. For example, if you want to use a command line or script with a path like: C:\Program Files)\Ivanti\Automation\Agent\agent.exe, encapsulate this path with double quotes: “C:\Program Files\Ivanti\Automation\Agent\agent.exe”. By default Microsoft Windows has 8.3 naming convention enabled, which means that when an application is installed that uses a long path or filename, Microsoft Windows will create an 8.3 name for it. However, it is possible to disable 8.3 names. This means that Microsoft Windows will not create an 8.3 name for long path or file names. If you then specify a long path or file name in a Task Execute Command, Microsoft Windows will fail to resolve the 8.3 name and thus the Task will fail.
  • In the optional Security Context, select Load user profile if the execution of the command requires information that is stored in the user's profile, for example the location of the user's Home Directory.
    Optionally, select Run with elevated privileges. If the provided credentials are not allowed to run elevated, the tasks will report an impersonation error.
  • The Task Execute Command can be an advanced Task. If you enter a complex command line, Ivanti Automation cannot interpret its validity. Therefore, always consider selecting Execute command using the Windows command interpreter and Redirect standard output and standard error to log files, and specifying whether the Task should fail if an error log is generated. These three options are enabled by default. Use these options in combination with Task fails/succeeds if the executable returns the following exit code to base the result of the Task on a specific exit code.
  • The options under Task fails/succeeds if the executable returns the following exit code allow you to specify numeric exit codes that indicate whether the task fails or succeeds.
  • Select Set parameter with exit code to place an exit code into a parameter, for use in another Task in the Module. For example, suppose you have configured a Module with a Task Execute Command and a Task that installs certain software. By using the option Set parameter with exit code in the Task Execute Command, you can use this parameter in a condition in the Task that installs software, to determine whether this Task should be executed.
  • Select Set parameter with standard output to place the standard output into a parameter, for use in another Task in the Module (e.g. a Query). The standard output parameter can contain a maximum of 4MB. This option is only available when the option Execute command using the Windows command interpreter is selected.
  • In the field Timeout command execution after, you can specify a maximum number of 9999 minutes (about 166 hours and 40 minutes). You can use parameters, functions and variables.
    • When 0 timeout is detected (when 0 was entered or when parameter, functions, variables translate to non-numeric values) the fallback will be the maximum timeout period (9999 minutes).
    • In certain situations, Agents can continue to execute the remaining commands in the script when the timeout expired. You can prevent situations like these by selecting one of the following options (by default, none of the options are selected):
      • Select Terminate process to exit any active process when the timeout expires.
      • Select Terminate process tree to exit any active process and any associated processes when the timeout expires.
  • In the optional field Grab log file, select a text file to be collected from the target machine. This file will be shown as an extra tab in the Job results named Grabbed Log.

Script tab

  • Scripts can be typed in directly. You can use Ivanti Automation functions, Ivanti Automation parameters and environment Variables in scripts. These Variables, functions and parameters will be parsed when the Task is executed.
  • Microsoft Windows commands are internal commands without their own executable (for example, the DIR command).
  • Use the File extension of script field to specify the file extension that Ivanti Automation should use. This extension is used to save the script as a script file in the specified format when the Task is executed. Ivanti Automation will save this file in the temporary folder on the Agent that executes the Task.
  • Use the Open in editor button to open an external editor that is associated with the specified file extension in the File extension of script field. This makes it easier to create complex scripts and troubleshoot existing ones. After creating or editing the script, it will be copied from the external editor to the Script tab. For more information on how to configure file associations, see
    • The Script tab has a limit of 64KB. If you use an external editor to edit a script, Ivanti Automation will disregard any characters that exceed this limit.
  • When executing this Task, log files will be generated and included in the detailed Job History. Before the Agent uploads these output log, error log or grabbed log files to the Dispatcher and make them available, the Agent will first compress the file if it has a size less than 100 MB.
    • In the following situations, the compression of that file will not take place. As a result, the file will not be uploaded:
      • The file size cannot be determined
      • The file is empty
      • The file is larger than 100 MB
    • The Job History will report if a file could not be uploaded because the file size could not be determined, or if the file size was larger than 100 MB. Empty files will not be reported. If a file cannot be uploaded, the outcome of the Task is not affected: the Task will still complete successfully, but the log file(s) that were not uploaded are not available in the Console.

When aborting a Job that contains Task Execute Command, any running scripts and processes will also be terminated.