Skip to main content

Queue Script

Summary

This script will schedule a script to run on a computer the next time it checks in.

Sample Run

Sample Run

Dependencies

Variables

Document the various variables in the script. Delete any section that is not relevant to your script.

NameDescription
TableNameThe custom table to be created.
GroupNameThe name of the group that is created by this script
GroupIDThe system ID for the group
RetrievalScriptThe script ID for the Run Queued Scripts script.
ATNameThe name of the designated Autofix action. (~Autofix - Run Queued Scripts)
ATCommentThe comment associated with the creation of the autofix action (Automatically Created Script by @ltrunbyuser@ This was created to run @ScriptName@)
ATGuidThe alert template needs a GUID statically set to (883f5185-289a-4763-8cc2-e4bf7dd1fb82)
AlertActionIDHolds the ID of the created Alert Action
AgentIDThis holds the ID of the alert action
MonitorSQLThis is the monitor conditions to check for the online agent.
SQLInsertThe insert statement for the process

User Parameters

NameExampleRequiredDescription
ScriptId7995TrueThe script ID for the script you wish to schedule
ScriptParametersmessage=Hi ThereFalseAny parameters that need to be passed to the above script.

Process

  1. Offline

    1. Create the table if it doesn't exist.
    2. If the group 'Machines with Queued Scripts' doesn't exist, create it and move on.
    3. Get the group ID for the above group.
    4. Check to see if the target machine is a member of the group; if not, add the computer to the group.
    5. Check to see if the alert template exists; if it doesn't, create it.
    6. Check to see if the alert template action exists; if not, create it.
    7. Check to see if the alert template is assigned to the group; if not, assign it.
    8. Check to see if the autofix action is assigned to the monitor; if not, assign it.
    9. Check to see if the target script exists in the custom table for that target computer; if it doesn't, add it to the custom table.
    10. Add the computer to the group.
  2. Online

    1. Schedule the script to run now on the machine.

Output

  • Script log