Video Screencast Help
Symantec to Separate Into Two Focused, Industry-Leading Technology Companies. Learn more.

ASDK 7.5 - Executing a Task using Powershell

Created: 29 Jul 2014 • Updated: 29 Jul 2014
LCode's picture
+3 3 Votes
Login to vote

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

  • Rename the .txt at the end of the filename so the extension is .ps1
  • ASDK libraries locally installed.
    You require symantec_asdk_ns_com_x64.msi or symantec_asdk_ns_com_x86.msi.
    You can find them in a subfolder of Symantec Installation Manager, below ...\Symantec Installation Manager\Installs\Altiris\
  • Local administrator rights to access/activate the ASDK libraries
  • Powershell executionpolicy must allow local script execution, eg. set executionpolicy to remotesigned

Configuration

There are a couple of variables that you need to modify in the script before it is ready to use.

  1. Change the name of the Altiris server in the line $global:altirisserver = "vm-alt-ns01"
  2. If HTTPS is required modify the line $global:https = 1 and set it to value 1
    When using HTTP set it to value 0
  3. Change the authentication parameters
  • For single sign-on, using your already logged-on credentials.
    Only modify the line $global:altirissso = 1 and set it to value 1
  • For sign-on with credentials provided in the script
    Modify the line $global:altirissso = 1 and set it to value 0
    Modify the line $global:altirisdomain = "ALTIRIS" and set it to your Active Directory Domain
    Modify the line $global:altirisuser = "Administrator" and set it to the AD account which has access to the Altiris Console
    Modify the line $global:altirispass = "Altiris01" and set the password of the AD Account.
  • Modify the line $computername = "COMPUTER01" and set it to the name of your test computer
  • Modify the line $taskname = "Run Script - Hello World" and set it to the name of a job/task you want to execute.