I recently received a question if it is possible to schedule a job/task using PowerShell. Executing a task is one of the possibilities of the Altiris ASDK TaskManagement library, something that I already used in the past when I wrote a Workflow webeservice to schedule a QuickDelivery. The attached PowerShell is an example based upon parts of that Workflow.
This example uses ExecuteTask to schedule a task to run immediately. You could use ScheduleTaskCustom or ScheduleTaskShared to execute a task on a specific schedule. The most important caveat in using the ExecuteTask or ScheduleTaskCustom methods is that they require a parameter called inputParameters which is actually a XML-syntaxed value. The following is an example of a valid value for inputParameters. The only thing that always needs to change is the GUID or GUIDs of computers which need to execute the task, in the example marked as cursive. When you want to schedule it on multiple computers you have to separate the values with a comma.
<inputParameters> <parameter> <name>@Assignedresources</name> <value>81043356-d7a6-44af-a673-20a467fdee14,ad2de238-66c7-4149-aea5-7d03af3ea5a9</value> </parameter> <parameter> <name>@CompRequirements</name> <value> <minWaitTime>2 minutes</minWaitTime> <maxWaitTime>60 minutes</maxWaitTime> <minCompletion>100 %</minCompletion> </value> </parameter> </inputParameters>
Furthermore the ExecuteTask needs the guid of the task to execute and a name for the instance of the task. The instance name (executionName) will be visible in the console. Syntax: string ExecuteTask(string taskGuid, string executionName, string inputParameters)
Requirements:
The following requirements need to be met when running the tool on a client workstation
Configuration
There are a couple of variables that you need to modify in the script before it is ready to use.