Symantec Developer Group

 View Only
  • 1.  Looking for samples of using the ASDK to deploy software

    Posted Oct 13, 2014 03:57 PM

    I'm looking for samples of using the ASDK to deploy software specifically using Web Services. I'm having trouble finding documentation regarding operations exposed in the Web Service or descriptions of which operations I would use to deploy software. I've looked at the ASDK CHM help file as well as on this support forum but have been unable to find what I'm looking for.



  • 2.  RE: Looking for samples of using the ASDK to deploy software

    Posted Feb 09, 2015 03:44 PM

    this is a code I worte to trigger a task/job from altiris (which can be a script or a software task) using Altiris Web Services. I am load the web services in powershell, but the concepted is the same if you change to another language.

    # check if client exist
    if (Test-Path 'C:\Program Files\Altiris\Altiris Agent\AeXNSAgent.exe' -erroraction silentlycontinue) { 
        # time in minutes
        $TaskRuntime = 0
    
        # this is just a sample task i created in Altiris, you can either supply the Task GUID or get it at run time (I am just supplying on this code)
        $TaskGUID = "{xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxxx}"
    
        # Name of the Task you create on Altiris
        $TaskName  = "Command DIR"
    
        # initializing Altiris Object
        $altirisagent  = get-wmiobject -class AltirisAgent_Client -namespace "root\CIMV2" -ErrorVariable +err -WarningAction SilentlyContinue 
    
        # get GUID info inside the brackets
        $Comp_GUID = $($altirisagent.MachineGUID | select-string -Pattern "{([A-Za-z0-9]{8}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{4}-[A-Za-z0-9]{12})}").Matches[0].Groups[1].Value
    
        # Altiris Credentials
        $username = "DOMAIN\USERNAME"
        $secureStringPassword = ConvertTo-SecureString 'USERNAMEPASSWORD' -AsPlainText –Force
    
        # create connection using the appropriated credentials
        $myCred = New-Object System.Management.Automation.PSCredential $username, $secureStringPassword
    
        # Starting Altiris Web Service
        $err=@()
        $taskManagement = New-WebServiceProxy -Uri "https://ALTIRIS_SERVER_NAME/Altiris/ASDK.Task/TaskManagementService.asmx?WSDL" -Credential $myCred -ErrorVariable +err
        if ($err.count -ge 1){ 
            Write-Host
            Write-Host " - Error: $err" 
        } else {
    
            # Execute Task
            $inputXml =	"<inputParameters>
                            <parameter>
                                <name>@AssignedResources</name>
                                <value>$Comp_GUID</value>
                            </parameter>
                            <parameter>
                                <name>@CompRequirements</name>
                                <value>
                                    <minWaitTime>1 minutes</minWaitTime>
                                    <maxWaitTime>$taskRuntime minutes</maxWaitTime>
                                    <minCompletion>95 %</minCompletion>
                                </value>
                            </parameter>
                        </inputParameters>";
    
            Write-Host " - Sending Task to Altiris Server ..."
            Start-Sleep 2
            $TaskResult = $taskManagement.ExecuteTask($taskGUID, $TaskName, $inputXml)
    
            if ($TaskResult.Guid -eq ""){
                Write-Host
                Write-Host "Error running Task ..."
            } else {
                Write-Host " - Task was successfully send it ..."
            }
        }
    } else {
        write-host 
    	write-host " - Altiris Client not found."
    }