This article demonstrates how to create (or rather, import) tasks into an NS and execute them on the fly.
Prerequisites: This workflow takes advantage of a pre-generated ASDK component as well as a generated web service component (generated against the ASDK Task Management Service on your NS).
I'm going to create a workflow that will create a text file on the hard drive (C:\) of the NS. The entire workflow is below:
Click to view.
We'll cover each of the components in the flow:
<item guid="{newGUID}" classGuid="{4f1b9b32-b5c6-4d83-8992-f73582217aac}"> <!-- Type: Altiris.ScriptTask.ScriptTask --> <!-- Assembly: Altiris.ScriptTask, Version=6.0.1404.0, Culture=neutral, PublicKeyToken=99b1e4cc0d03f223 --> <name>NewName</name> <alias /> <ownerNSGuid>{7e4084c7-11f8-4de4-a8e2-0546461405ad}</ownerNSGuid> <productGuid>{9f9a80fc-2d71-4b08-a1ad-fb146b4af2c6}</productGuid> <itemAttributes>Normal</itemAttributes> <itemLocalizations> <culture name=""> <description>Runs a script on computers</description> <name>NewName</name> </culture> <culture name="en"> <description>Runs a script on computers</description> </culture> </itemLocalizations> <platform configuredProviderGuid="00000000-0000-0000-0000-000000000000" /> <remoteExecAdvanced> <priority value="Normal" exclusive="True" /> <kill enforce="True" maxMinutes="30" /> </remoteExecAdvanced> <scriptText type="JavaScript">var fso = new ActiveXObject("Scripting.FileSystemObject"); var a = fso.CreateTextFile("c:\\woohoo.txt", true); a.WriteLine("yoohoo."); a.Close();</scriptText> <scriptAdvanced collectOutput="False" username="" password="" window="ShowNormal" /> <parentFolderGuid>455ae0db-ec74-455b-b262-89421c96908d</parentFolderGuid> <security owner="@APPLICATION_ID" inherit="True"> <aces> <ace type="reserved" name="@APPLICATION_ID"> <permissionGrants> <permissionGrant guid="{ac296df1-eb40-4592-899f-25d5c07d45f6}" name="Write" /> <permissionGrant guid="{819dae1e-b1a5-4643-81a1-26ef95feb8a8}" name="Change Permissions" /> <permissionGrant guid="{983a2d22-7a82-4db0-a707-52c7d6b1441e}" name="Read" /> <permissionGrant guid="{eca6254f-5017-4730-9b3f-5add230829b7}" name="Delete" /> <permissionGrant guid="{726b1c09-7108-450d-ae24-5f8e93135ed6}" name="Clone" /> <permissionGrant guid="{4ddc04c3-f0a5-4e88-84aa-c44c8c5ebcc4}" name="Read Permissions" /> <permissionGrant guid="{fbce1052-3bcf-4734-9701-d5bdb08fe64c}" name="Run" /> </permissionGrants> </ace> </aces> </security> <itemReferences> <itemReference guid="{c6c14a32-2dd0-458c-9300-ab24e8d016fd}" hint="tasktypeitemfortask" type="DependentChild"> <item guid="{c6c14a32-2dd0-458c-9300-ab24e8d016fd}" classGuid="{c7bf6fbb-8067-4a1b-9dea-f37fd7d0cfd4}"> <!-- Type: Altiris.ScriptTask.ScriptTaskType --> <!-- Assembly: Altiris.ScriptTask, Version=6.0.1404.0, Culture=neutral, PublicKeyToken=99b1e4cc0d03f223 --> <name>Script</name> <alias /> <ownerNSGuid>{7e4084c7-11f8-4de4-a8e2-0546461405ad}</ownerNSGuid> <productGuid>{c5c92942-41a8-4221-80a5-d41b3d585701}</productGuid> <itemAttributes>Normal</itemAttributes> <itemLocalizations> <culture name=""> <description>Script Task Definition Item</description> <name>Script</name> </culture> </itemLocalizations> <parentFolderGuid>b677de98-acc5-40be-91ea-5a6ef5a3f784</parentFolderGuid> <security owner="@APPLICATION_ID" inherit="True"> <aces> <ace type="reserved" name="@APPLICATION_ID"> <permissionGrants> <permissionGrant guid="{ac296df1-eb40-4592-899f-25d5c07d45f6}" name="Write" /> <permissionGrant guid="{819dae1e-b1a5-4643-81a1-26ef95feb8a8}" name="Change Permissions" /> <permissionGrant guid="{983a2d22-7a82-4db0-a707-52c7d6b1441e}" name="Read" /> <permissionGrant guid="{eca6254f-5017-4730-9b3f-5add230829b7}" name="Delete" /> <permissionGrant guid="{726b1c09-7108-450d-ae24-5f8e93135ed6}" name="Clone" /> <permissionGrant guid="{4ddc04c3-f0a5-4e88-84aa-c44c8c5ebcc4}" name="Read Permissions" /> <permissionGrant guid="{c27cdc0e-67aa-415a-9288-c47b9a8e7cc0}" name="Create" /> </permissionGrants> </ace> </aces> </security> <itemReferences /> </item> </itemReference> </itemReferences> </item>
<inputParameters> <parameter> <name>@AssignedResources</name> <value>CollectionToRunTaskAgainst</value> </parameter> <parameter> <name>@CompRequirements</name> <value> <minWaitTime>1 minutes</minWaitTime> <maxWaitTime>1 minutes</maxWaitTime> <minCompletion>1 %</minCompletion> </value> </parameter> </inputParameters>
After running this flow, the task should create a little text file at the C:\ level. While this is a fairly minor example, hopefully it demonstrates the ability of building, creating and executing custom tasks on the NS via Workflow.
Thanks reecardo for your rapid response :-)
From the console I have created a Filter and put its GUID in the parameter, but unfortunately crash an error in the last component "Execute Task" :
Yes, filter/collection is what I meant... I forgot the nomenclature changed between 6 and 7
reecardo,
When you say "I created an empty computer collection on the NS and added the NS machine itself to it. "
Are you refering to create a Filter, isnt it?
Thanks
If you know the GUID of the task in the SMP, you can run it... you don't have to have the workflow create it for you.
You can get the GUID of the task my just checking its properties I believe.
Attached is a package that shows how to do this in 7.0. I've basically swapped out the NS6 comps for SMP 7 comps. This package should also make an appearance in a video soon. Just rename the .zip to .package.
Another good thing I omitted from this flow (and vid)... it would be a good idea to REMOVE the instance of the task so you don't clutter your SMP. This can be done with a Delete Item Component (a generated ASDK component that comes loaded by default)
This is absolutely still valid with 7.*... just remember to use the SMP components geared towards SMP 7 (their namespace will begin with Altiris7.*)
I'm using this method now to interact with Virtual Machine Management tasks in the SMP. Hopefully I'll have some content available for the store soon.
Is this still valid for Ns 7.1 Jobs and Tasks with WF 7.1?
Kindest regards,
QuietLeni
What does this do? It looks like it's causing my task to time out because I am running an imaging job. Should both min and max be set to a larger number or do I only need to change MAX to something like 180 instead of 10?