Queue Script Next Checkin
Purpose
This solution provides a way to schedule a script in Automate to run on a computer the next time it checks in. It is intended for offline computers, in cases where you are unsure of when this computer will become available again; however, it can be utilized to schedule any script to run on any machine.
Associated Content
Content | Type | Function |
---|---|---|
CWM - Automate - Custom Table - plugin_proval_queued_scripts | Custom Table | Stores queued scripts and their requested parameters. |
'Machines With Queued Scripts' Group | Group | Members will be computers with pending queued scripts. The group has the CWM - Automate - Script - Run Queued Scripts script scheduled to run every 3 days. |
CWM - Automate - Script - Queue Script | Script | Creates the table, group, and scheduled script on the group if required. Adds the target agent to the created group and stores the target script ID and parameters in the custom table. |
CWM - Automate - Script - Run Queued Scripts | Script | Collects script information for the target agent from the table and executes the script(s) with the requested parameters. The script then removes executed script entries from the custom table and removes the computer from the group. |
CWM - Automate - Monitor - Monitor~~ Autofix - Run Queued Scripts | Internal Monitor | This monitor is created by the CWM - Automate - Script - Queue Script automate script. It returns failed if the computer is offline, and success when online. |
Implementation
Import both scripts.
Run the CWM - Automate - Script - Queue Script script; this sets up the environment on the first run. No additional setup is required.
FAQ
-
How does this work?
- CWM - Automate - Script - Queue Script
- If you run CWM - Automate - Script - Queue Script on an online machine, the script will schedule the desired script to run immediately.
- The script, CWM - Automate - Script - Queue Script, creates the custom table, CWM - Automate - Custom Table - plugin_proval_queued_scripts, if it does not exist, when running on an offline machine.
- The script, CWM - Automate - Script - Queue Script, creates the 'Machines With Queued Scripts' group if it does not exist and assigns an internal monitor to that group if it's not already assigned. This monitor will check for a recent check-in from the agent; if a recent check-in has been found, then the monitor autofix will run CWM - Automate - Script - Run Queued Scripts.
- The script, CWM - Automate - Script - Queue Script, then adds the target computer to that group if the computer is not already a member.
- After the computer is verified to be a member of the group, the script, CWM - Automate - Script - Queue Script, will populate the custom table, CWM - Automate - Custom Table - plugin_proval_queued_scripts, with the requested script and parameters, if that computer does not already have that script scheduled.
- CWM - Automate - Script - Queue Script
-
'Machines With Queued Scripts' Group
- The group, 'Machines With Queued Scripts', holds all computers that have any queued scripts using this solution.
- This group's intention is to ensure that only computers with queued scripts are targeted with the CWM - Automate - Script - Run Queued Scripts script.
-
CWM - Automate - Custom Table - plugin_proval_queued_scripts
- The custom table, CWM - Automate - Custom Table - plugin_proval_queued_scripts, is intended to hold a memory of any script for any target machine that you would like to execute the next time the computer checks in.
-
CWM - Automate - Script - Run Queued Scripts
- The script, CWM - Automate - Script - Run Queued Scripts, is executed from an internal monitor's alert action 'Monitor~~Autofix - Run Queued Scripts'.
- This script will execute any script(s) found in CWM - Automate - Custom Table - plugin_proval_queued_scripts for the target machine with its associated desired parameters either silently or with natural logging.
- This script will remove any queued scripts from CWM - Automate - Custom Table - plugin_proval_queued_scripts upon execution of that script.
- This script will remove the computer from the group 'Machines With Queued Scripts' at the completion of the script.
-
I have scheduled a script on a target machine, and I want to schedule that same script again. Can I?
Unfortunately, no. The system safeguards against duplicate entries in the CWM - Automate - Custom Table - plugin_proval_queued_scripts table and will not allow a target to schedule the same script on the same computer twice at the next check-in. -
I have been running this, and I am noticing that my scripting engine is suffering. What can I do?
A silent parameter is present in the CWM - Automate - Script - Run Queued Scripts script. Modify the CWM - Automate - Script - Run Queued Scripts script, setting the script's global silent switch to 'Yes'. This will transfer the running of the queued scripts from the script engine to simply being called directly from the CWM - Automate - Script - Run Queued Scripts script. Keep in mind this means that your queued scripts will not show up in the script history or on the computer's scripts page, and all logging for any script called in this manner will be displayed under the CWM - Automate - Script - Run Queued Scripts log on the computer's script page.