How to schedule / Execute a task using the ASDK with powershell

book

Article ID: 178207

calendar_today

Updated On:

Products

Task Server

Issue/Introduction

 

Resolution

At times you may way to use your own code to schedule a task through power shell, that can be done by using the following powershell script task:

 

$compname = "%COMPNAME%"
$URI = "http://localhost/Altiris/ASDK.Task/TaskManagementService.asmx"

$proxy = New-WebServiceProxy -Uri $URI -Class Task -Namespace webservice -UseDefaultCredential

$inputXml = @"
<inputParameters>
    <parameter>
        <name>@AssignedResources</name>
        <value>%COMPID%</value>
    </parameter>
    <parameter>
        <name>@CompRequirements</name>
        <value>
                <minWaitTime>1 minutes</minWaitTime>
                <maxWaitTime>10 minutes</maxWaitTime>
                <minCompletion>95 %</minCompletion>
        </value>
    </parameter>
    <parameter>
        <name>@OverrideMaintenanceWindows</name>
        <value>
            <boolean>true</boolean>
        </value>
    </parameter>
</inputParameters>
"@

$proxy.ExecuteTask("15f4a911-63f6-4132-bf28-d7c0081f7625" ,"PowerShell Execute on $compname", $inputXML)

 

Additional Information

DESCRIPTION :

See the Altiris Task ASDK for help and details