Automic Workload Automation

 View Only
  • 1.  Powershell question

    Posted Dec 06, 2017 07:56 AM

    I know this is an Automic forum but ...

    I have created a workflow with hundreds of jobs.  I now want to add a default postcondition to all the jobs in all the workflows as below:

    ljxgkxeiem48.png" width="800">

    Rather than applying this manually I have been trying to amend the xml for the workflow attempting to add this for every 'JOBS'.

    I can use powershell to extract the node I have entered manually and can find all the nodes i want to amend ... but I am struggling to insert the additional node into the xml.  I have been using Appendchild but that just seems to move the logic from one parent to the next ... ending up with the last JOBS I come across.

    Anyone have any ideas or can this be done any other way?

    I can provide the xml examples and powershell used so far if this question is deemed ok here.


  • 2.  Powershell question

    Posted Dec 06, 2017 08:20 AM

    No need to worry about nodes. Just copy the innerXML of a reference task ;-). If you're into Powershell - I provide a module that allows you to work natively with the AE. Ping me or check my signature links if you're interested in.


    $referenceTaskName = 'SOURCE.JOB' [xml]$xmlDefinition = Get-Content .\pp.xml $copyFrom = Select-Xml -xml $xmlDefinition -XPath ('//task[@Object="' + $referenceTaskName + '"]') $pasteTo = Select-Xml -xml $xmlDefinition -XPath ('//task[@Object!="' + $referenceTaskName + '" and @OType="JOBS"]') $pasteTo | % { $_.Node.postconditions.innerXML = $referencetask.Node.postconditions.innerXML } $'c:\temp\output.xml')
    You might do the reference selection also based on the lnr etc. Regards Joel

  • 3.  Powershell question

    Posted Dec 06, 2017 08:22 AM
    Cheers Joel will give it a go :)

  • 4.  Powershell question

    Posted Dec 06, 2017 08:42 AM
    Spot on Joel ... wish i had asked this question this time yesterday :) cheers!

  • 5.  Powershell question

    Posted Dec 06, 2017 08:46 AM

    By the way.. same logic in my WFC module :-):

    # Open connection with predefined profile $ae = New-aeConnection -profile predefinedTest # 1st: open JOBP in read-write mode $jobp = Open-aeObject -ae $ae -name JOBP.DEMO -readwrite # 2nd Example: select reference task by name $copyFrom = Get-aeJOBPTasks -ae $ae -object $jobp | Where-Object Name -eq 'JOBS.REFERENCE' # 3rd: Determine tasks in workflow that should receive the postcondition setting $pasteTo = Get-aeJOBPTasks -ae $ae -object $jobp | Where-Object { $_.Name -ne 'JOBS.REFERENCE' -and $_.Type -eq 'JOBS' } # 4th: Since we have source and destination, paste the postconditions Copy-aeTaskSettings -srcTask $copyfrom -dstTask $pasteto -postConditions # 5th: Save and close workflow Save-aeObject -ae $ae -object $jobp -close