Construct a Policy (script) using Automation Manager

You can construct a policy (script) using the Automation Manager in a few steps. The following example covers the process of creating a policy to check for the existence of a folder and, depending on the result, the action to take as specified in an If conditional statement.

The creation of this policy is split into six steps:

When you submit passwords in your custom automation manager scripts, Automation Manager validates those passwords to ensure they do not include the following unsupported characters: " ‘ / \ $ `

If there are unsupported characters, the validation field indicates which characters are not supported so you can adjust your passwords.

Create a New Policy

  1. Launch the Automation Manager
  2. Create the policy:
    • Click New Policy in the North-pane, or
    • Click the plus button in the menu bar, or
    • Go to File > New
  3. Enter a descriptive Name
  4. Provide information on its usage, parameter requirements... in the Description
  5. OK to proceed

am_new_policy

Policy Workflow (add objects)

The policy workflow determines the objects (tasks) run sequence. Add objects to the policy in their execution order.

  1. Browse or Search through the left Object pane for the target component
  2. Drag and drop this object onto the Policy Builder frame where you want it to run in the policy

To display description and parameter information for the object in the right Help Panel (where enabled in the View menu). Highlight the object in the policy.

We will cover the objects required for this policy and the sequence they are entered:

  1. Choose the Folder Exists object
  2. Drop Folder Exists onto the policy between Input and Output
    • This object checks whether the given folder exists
  3. Chose an If object
  4. Drop If under Folder Exists in the policy
    • This object instructs the script to perform an action when the specific condition is met. Add the action object in the If component's Then field.
  5. Choose the Create Folder object.
  6. Drop the Create Folder object under If in the Then condition (Drop objects here)
  7. This object creates a folder with the given path.

Drag and drop objects to reorder their sequence in the policy.

Configure Variables and Values

After the objects are added to the policy and the layout is complete, the next stage is to begin populating the variables and values.

Folder Exists

Identifies the folder to search for.

Input Parameter

Folder

Pre-populate the field to always check whether a specific folder exists or link the parameter to another object or Input Parameter. This field requires the full path to the folder.

In our example we will link this field to an Input Parameter entered by the Dashboard user.

If

Checks whether the specified folder exists.

Input Parameters

Variable

Click the link (chain) icon beside the Variable: field and select

Objects: Folder Exists

Output Parameters: Conditional

OK to save

Condition

Choose equals

Value

Enter False

Then

Triggers the Create Folder object where the specified folder does not exist.

Create Folder

Pre-populate the field to always check whether a specific folder exists or link the parameter to another object or Input Parameter. This field requires the full path to the folder.

In our example we will link this field to the Input Parameter entered by the Dashboard user.

If Object and Variable Link: Folder Exists

Enter Input Parameters

The parameters processed by the policy vary depending on the intended usage of the script. When using Input Parameters the user may be prompted to enter the parameters when configuring the script on the Dashboard as a Check or Automated Task.

Our example requires two Input Parameters to prompt the user to enter both the Folder Exists and Create Folder locations.

Field Note Folder Exists - Example Input Parameters Create Folder - Example Input Parameters

Name

Variable name: cannot contain spaces and must be unique

CheckFolder

AddFolder

Display

The label of the field as it appears in the Dashboard

Check for this folder

Create this folder

Type

Choose the input type from the drop-down:

Date

Numeric value indicating a calendar date in the format mm/dd/yyyy hh:mm:ss

Number

Numeric value

Password

Security password

String

Alphanumeric character string

String

String

Value

The data input field. This can be left blank, or pre-populated to provide an example for the user adding the Script Check or Automated Task.

e.g. C:\Users\John.Doe\Documents\My Projects

e.g. C:\Users\John.Doe\Documents\My Projects

Folder Exists - Example Input Parameter Dialog and Create Folder - Example Input Parameter Dialog

Link Input Parameter to Object

After creating the Folder Exists and Create Folder Input Parameters, the next stage is to associate these inputs with a object.

Folder Exists

  1. Go to the Folder Exists object in the policy
  2. Click the link button against Folder: field to open the Object Link dialog
  3. Under Objects choose Input Parameters
  4. In Output Parameters select the Folder Exists parameter (i.e. CheckFolder)
  5. OK to save

Create Folder

  1. Go to the Create Folder object in the policy
  2. Click the link button against the Folder: field to open the Object Link dialog
  3. Under Objects choose Input Parameters
  4. In Output Parameters select the Create Folder parameter (i.e. AddFolder)
  5. OK to save

Folder Exists - Example Object Link Dialog and Create Folder - Example Object Link Parameters

Test Policy and upload to the Dashboard for distribution

Once all the objects are added to the policy and the variables, values and parameters populated, the final stage is testing. Testing ensures the script will work as expected before uploading to the Dashboard and deploying across mutliple devices.

  1. Test the policy locally
    • Click the play icon on the toolbar, or
    • Press Ctrl + F5, or
    • Go to File > Run
  2. Enter Input Parameters where prompted
  3. To stop the policy at any time before it completes
    • Click the stop icon on the toolbar, or
    • Press Shift + F5

To allow you to follow the policy's execution process it logs its results to the Output pane. Where problems are encountered they appear in the Errors section.

Use the Debug option, to execute the policy one component at a time to allow for easier reviewing. Implement Breakpoints to stop the policy at specific points.

If testing proves successful, the next steps is to save the policy locally (save icon on the toolbar or File > Save) then upload to the Dashboard for distribution.

  1. Log into the Dashboard
  2. Go to Settings > Script Manager
  3. Click New, populate the required information and upload the script as a Windows Script Check or Automated Task

Automation Manager - Enter Input Parameters and Policy Output and Script Manger - Add User Defined Scripts Dialog

am_test_run

Exit codes returned by the PowerShell script are only consumed within the Run PowerShell Script module and not passed back to the Dashboard.

To generate a Dashboard failure where the PowerShell script fails, add an If or If/Else Control Flow condition and include the Fail Policy module.

For example, Run PowerShell Script (Extensions) > If (Control Flow) > ThenFail Policy (Control Flow).

What do you want to do?