Copying an ARS scheduled task

Ok so I have to admit right up front I failed – I can’t create an ARS scheduled task but I can copy the parameters and schedule from one task to another which was why I was trying to do this in the first place.  Back in June 2014 I’d tried to copy a task and posted on the Quest ( now Dell software ) support site a question http://en.community.dell.com/techcenter/iam/f/4817/t/19589175 but this got ZERO responses :-(.

Anyway creating a task is relatively simple, what I wanted really was a way to copy the parameter list and their values.  This is reasonably simple:

Grab the task you want to clone:

$TaskObj = Get-QADObject `
  -Identity $Global:taskDN `
-Connection $ARSConnection `
-IncludedProperties edsaParameters,edsaXMLSchedule,edsaModule

the edsaModule is the script that the scheduled task runs the other two attributes store the parameters and the schedule should you want to copy those too.

Once you have the existing task and you have created the new task just issue this command and the values are copied over for you:

Set-QADObject `
-Identity $NewTaskObj.DN `
-ObjectAttributes @{edsaParameters=$TaskObj.edsaParameters}

Advertisements

2 thoughts on “Copying an ARS scheduled task

  1. runCMD@live.com

    great post and timely find … even if this blog post is long in the tooth. Your example inspired me to play around with the capabilities of viewing current status of a known ARS scheduled task.
    What I can’t seem to crack open – is how to enumerate / list all scheduled tasks under our root task container. I’ll keep plugging at it, but wanted to say thanks for the inspiration. Here’s my too-simple script to query the status of a known task by DN. ( in the GUI, I opened advanced properties on the task to grab the DN )

    I used the tick ` at the end of each expression line to make it easier to read.
    change the qadservice host to connect to – and the DN for your task.

    add-pssnapin quest.activeroles.admanagement
    connect-qadservice -service -proxy

    $task = Get-QADObject -Identity “CN=MY TASK(Update ARS/AD),CN=MY Scheduled Tasks,CN=Scheduled Tasks,CN=Server Configuration,CN=Configuration” -IncludeAllProperties -proxy

    $task | fl @{Name=”Task State”;Expression={if($task.edsvaIsReadyToTerminate){“Running”}else{“Not Running”}}}, `
    @{Name=”Last Run Time”;Expression={$_.edsaLastRunTime}}, `
    @{Name=”Next Run Time”;Expression={$_.edsvaNextRunTime}}, `
    @{Name=”Last Task Message”;Expression={$_.edsvaTaskStateString}}, `
    @{Name=”Description”;Expression={$_.edsvaScheduleDescription}}, `
    @{Name=”Execution Host”;Expression={$_.edsvaServerNameToExecute}}

    Result

    Task State : Not Running
    Last Run Time : 6/6/2016 5:04:39 PM
    Next Run Time : 6/7/2016 5:35:00 AM
    Last Task Message : Task execution was completed
    Description : At 04:35 every days, starting 02.05.16
    Execution Host : MYHOST.MYDomain.com

    • Hi, thanks for commenting it sometimes feels quite lonely almost like talking to yourself when you blog.

      For tips on writing code for ARS, especially if you have an issue, I highly recommend using the Dell software support forums. I post there quite regularly answering queries when I can – there are a couple of guys who are so fast responding it’s hard to beat them.

      Any way you mentioned you wanted to enumerate all of the scheduled tasks. The trick here is actually applicable to lots of powershell enumeration tasks. If you give the commandlet an absolution identity ( using the identity parameter ) then it will return just that one object. You’d think you could then list all the child objects, you can after all often get the parent object with the .parentContainer or .parentContanerDN properties.

      How to do it then is not to give the commandlet an absolute object to bind to. Instead use the -searchRoot switch and target a container/OU and it will return all of the objects below the target. Use the -searchScope to control if it returns just the immediate objects below the container or all of the objects in child containers too (onelever or subtree). Use the -type switch to limit the types of object that are returned although taking a quick look it appears both the tasks and containers are being returned as ArsDirectoryObjects. You could use a WHERE clause and use the classType to filter, the tasks are edsScheduledTask and the containers are edsScheduledTasksContainer. That should give you enough to go on.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.