Advanced Features : Scripting : Configuring scripts
 
Configuring scripts
To configure, import, export, or run scripts, go to the Device Manager tab, expand an ADOM view in the tree menu, and then select Script > Script. The script list for the selected ADOM will be displayed.
Figure 153: Script list
The following information and options are available:
Create New
Select to create a new script.
Import
Select to import a script from your management computer. Enter a name, description, select TCL type if applicable, and browse for the file on your management computer. Select submit to import the script to FortiManager.
Run
Select a script in the table, right-click, and select Run in the menu to run the script against the target selected. When selecting to run a script against a policy package, select the policy package from the drop-down list in the dialog window. When selecting to run a script against a device or database, select the device in the tree menu in the dialog window.
New
Select a script in the table, right-click, and select New in the menu to create a new script.
Edit
Select a script in the table, right-click, and select Edit in the menu to clone the script selected.
Clone
Select a script in the table, right-click, and select Clone in the menu to clone the script selected.
Delete
Select a script in the table, right-click, and select Delete in the menu to delete the script selected.
Export
Select a script in the table, right-click, and select Export in the menu to export the script as a .txt file to your management computer.
Select All
Select Select All in the right-click menu to select all scripts in the table and select Delete to delete all selected scripts.
Name
The user-defined script name.
Type
The script type.
Target
The override script target. One of the following:
FortiGate Directly (via CLI): Run on FortiGate Directly (via CLI)
Policy Package: Run on Policy Package, ADOM Database, or Global Policy
DB: Run on DB
Description
The user-defined script description.
Last Modified
The date and time that the script was last modified.
Run a script
To run a script:
1. Browse to the ADOM script list for the ADOM that contains the script you would like to run.
2. Select the script, then right-click and select Run from the pop-up menu.
 
Scripts can also be re-run from the script execution history by selecting the run button, . See “Script history” for information.
The Execute Script dialog box will open. This dialog box will vary depending on the script target. You will either be able to select a device or devices (left image below), or a policy package (right image). See “Override Script Target” for more information.
Figure 154: Execute script dialog boxes
3. Select OK to run the script.
The Run Script dialog box will open, showing the progress of the operation and providing information on its success or failure.
4. Selecting the Details option will expand the dialog box to show the details table, with details of the success or failure of the script.
Under the History column in the details table, you can select the History icon to open the script history for that device, and the View Script Execution History icon to view the script execution history for that device.
5. Close the Run Script dialog box when finished.
Add a script
To add a script to an ADOM:
1. Browse to the ADOM script list for the ADOM in which you will be creating the script.
2. Select Create New, or right-click anywhere in the script list and select New from the pop-up menu, to open the Create Script dialog box.
Figure 155: Create a new script
3. Enter the required information to create your new script.
Script Name
Enter a name for the script.
View Sample Script
This option is not in use.
Description
Optionally, enter a description of your script.
Script Detail
Enter the script itself, either manually using a keyboard, or by copying and pasting from another editor.
Override Script Target
Select to change the script target. This settings will affect the options presented when you go to run a script. The options include:
Run on FortiGate Directly (via CLI)
Run on Policy Package, ADOM Database or Global Policy
Run on DB (default when Override Script Target is not selected).
Note: The Run on DB option is available when editing an existing script.
Advanced Device Filter
Select to adjust the advanced filters for the script. The options include:
OS Type (select from the drop-down list)
OS Version (select from the drop-down list)
Platform (select from the drop-down list)
Build
Device (select from the drop-down list)
Hostname
Serial No.
4. Select OK to create the new script.