Execute Scripts

You can execute a script only after it is approved. A new job is created when you execute a script and is listed under the Jobs tab.

To know more on how to approve a script, refer to Reviewing and Approving Scripts.

You may also want to test the script before executing. To know more about script test, refer to Testing Scripts.

If an asset job is in a pending state, no new asset job is created for that asset on the next execution of the same script within 14 days from the last execution. For more information, refer to Optimization of Asset Job Handling in CAR.

Reboot lets you reboot the host and allow the script execution to come into effect. You can specify the time after which you want to start the reboot. The time buffer must be for a minimum of ten minutes and a maximum of forty-eight hours. You can set the time by choosing the duration from the drop-down menu. Reboot is applicable only for Windows scripts.

Reboot takes place only if the CAR job status is 'Execution Passed'.

To execute a script, follow these steps:

  1. In the Scripts tab, select a script and then click Quick Actions menu, click Run Now.

    The Run Now option is active only if the script is approved.

    Policy Audit Fix Scripts can be executed only on PAF enabled assets.

  2. In the Select Assets screen, define the scope of your script by selecting assets and/or by including asset tags. You can select any of the following options for asset selection while executing a script:
    1. Manual Asset Selection
    2. Import Assets
    3. Automated Assets Selection
    a.  Manual Asset Selection:

    You can manually select the assets you want. 



    When executing a parameterized script, you can modify the Script Parameters value as required.

    If you want to specify assets, follow these steps:
  • In the Add Assets section of the Select Assets page, click the + sign.
  • In the Select Assets page, select the assets that you want to include in the script run and then click Apply.

      If you want to include asset tags, follow these steps:

  • In the Add Asset Tag section of the Select Assets page, click the + sign.

  • In the Select Tags page, select the tags that you want to include in the script run and then click Apply.

You can add All or Any asset tags.

  • In the Exclude the Assets section, click the + sign.
  • In the Select Assets page, select the assets that you want to exclude and then click Apply.  The Exclude host for the tags option is enabled only when you include asset tags. At times, you may want to exclude certain assets that are assigned to the tag that you have selected in the previous step. This option enables you to specify assets that you want to exclude in the script run.
     b.  Import Assets: 
  • Upload a CSV file containing asset names and use those assets to execute a script and schedule it. It helps you quickly target multiple assets at a time. 
  • Click Browse to upload the CSV file from your destination. Before execution, all imported assets are automatically validated to identify any errors or inconsistencies.
    The feature supports both immediate execution and scheduled script execution workflows, providing flexibility in managing asset imports.
    • CSV file should be in the comma-delimited format. 
    • CSV files are allowed up to 2 MB in size and support up to 5,000 assets per import.
    • The CSV file must contain only unique asset names. Any duplicate asset names found in the CSV file are marked as invalid with the reason Duplicate assetEnsure each asset name appears only once in the file before uploading.

    The script runs on the assets listed in the uploaded CSV file. After uploading the CSV file, you can download a report that lists the assets that failed validation. Each entry includes the asset name and a validation message that explains why the asset was excluded.

  • The CSV file includes possible reasons for validation failures and their corresponding conditions:

    Validation Message Description
    Not found The asset name does not exist in your account.
    Lab asset The asset is a lab asset and is only available in test mode.
    Blocked asset The asset is in the global exclusion list and cannot be scheduled.
    Platform is invalid The asset's operating system does not match the script's platform.
    This is not lab asset In test mode, only lab assets are eligible for validation.
    Duplicate asset The same asset name appears more than once in the CSV file.
    Limitations 
    • Asset names must exist in the database to pass the validation.
    • Failed asset download information is available for a limited duration after validation.

C. Automated Assets Selection       
  • Use the Automated Asset Selection option to identify and select assets for script execution using a QQL query. The QQL query allows you to filter assets based on the provided QQL criteria. This helps you quickly target the required assets while reducing manual selection effort. 
  • Enter a valid QQL query in a Search field. You can Preview the results to view the assets that match the query. 

           Example: operatingSystem.name:windows

      

3.  Select the following toggle switch as required:

  • Bypass PowerShell Execution Policy: Use this toggle to specify if you want to override the PowerShell execution policy on Windows agents. When you switch this toggle to Yes, both signed and unsigned scripts are executed on the agent irrespective of the PowerShell execution policy set on the asset.

    This option is displayed only when you execute a Windows PowerShell script.

  • Reboot Host after Script Execution: If you turn this toggle to Yes and set a delay, the system waits for the selected duration after the script execution completes and then initiates the reboot process.
    The Delay before Reboot option enables you to specify a time period before the system is rebooted following the execution of a script.
    This ensures a smooth transition between the execution of the script and the reboot process, allowing you to manage system changes in a controlled and efficient manner.
  • Monitor this script’s output for any changes: Use this toggle to share the script output to monitor and detect any changes to the FIM assets and displays those changes as events in FIM.

4.  Click Execute Script.

You cannot execute the same script within a span of 5 minutes.

You can view the status of the executed script under the Jobs tab.

Unlike the evaluated scripts, the name of the executed script is displayed as it is, without any suffix or prefix.

Limitations

Car Script execution does not support parent-child tag relationships. Only directly assigned tags are recognized by CAR.

Related Topics

Creating Scripts

Testing Scripts

Reviewing and Approving Scripts

Exporting and Importing Scripts

Scheduling a Script Execution