Combining Sync tasks and Scheduled tasks into one "item" to make running manually much simpler.

We currently have a daily process that runs multiple sync jobs all timed one hour apart. In between those sync jobs are scheduled scripts to make additional changes based on the sync job. This runs fine except when the process needs to be stopped because a downstream system is not ready for sync. My plan is to try and combine the sync jobs and scheduled tasks into something (workflow, manually run task, external powershell script) so that this entire process can be run by the click of a button. First off as you can see, I am not exactly sure the best way to combine the above steps and what container would hold those steps. Here is the example morning process:

6:00AM Sync runs against system A

6:30AM multiple scheduled tasks run.

7:00AM Sync runs against system B

7:30AM multiple scheduled tasks run.

8:00AM Sync runs against system C.

8:30AM multiple scheduled tasks run.

Because all of these steps need to run in order, if the process needs to be paused because of a downstream system and then run manually, it is painful to run and wait, run and wait, run and wait.

Any suggestions on how to attack this?

I see that by using Connect-QCService and Start-QCWorkflow I can run the sync jobs manually from an external Powershell script. Can I also add in the running of the scheduled tasks to this script? If so then that would be a solution. And yes the scheduled tasks use included library scripts also if that is a deal breaker.

Thanks,

Rick

ARS 7.4.5 soon to be 7.6.1

  • As a follow-up to this, I can see these attributes when I pull in a scheduled task:

    Connect-QADService -Service "myServerName" -Proxy

    $arsScheduledTask = Get-QADObject -Type edsScheduledTask -Identity "TestTask" -IncludeAllProperties

    The following attributes are found: $arsScheduledTask.edsvaExecuteNow = null and $arsScheduledTask.edsaforceexecution = False

    Can this be used to run a scheduled task from Powershell externally? Will setting one of these to true or 1 tell the server to run the task now?

  • You can definitely fire your AR scheduled tasks with PoSh as you suggest.  

    Depending on whether your scripts are modifying AD properties or not, if they are you might consider using AR Change Workflows which would react to attribute changes being made by the scripts and thus help manage your sequencing.

    This is one of those cases where the devil is very much in the details as far as solutioning the best combination of approaches.

  • Thanks. Yes they are modifying AD properties but at this time, I kind of just wanted to combine what is already tried and true (tested) but put it together into one manually run script so that when things fail overnight the entire process can be run with the click of a button. So far I have figured out how to run the scheduled workflows, I am still stuck on how scheduled tasks can be run inside this same script. Is it as simple as querying for the Scheduled Task (like I did above) and then setting a bit to rerun it right now?

    I like your idea of using change workflows to update this entire overnight process. I will look into that for a future cleanup of this process.

  • Here's a snippet for you for firing a scheduled task:

    set-qadobject -proxy -identity "CN=Test Task,CN=Scheduled Tasks,CN=Server Configuration,CN=Configuration" -objectAttributes @{edsvaExecuteNow=$true}

  • Interesting thing I noticed today, it doesn't appear that the ARSConnection value does what I thought it did. I thought that using it would start the scheduled task on a particular server. It doesn't. It starts from the server you set the executenow attribute from. Is there a way to start the job from a particular server?

    $task_fullname = "myScheduledTask"
    $servicename = "ARSServerNumber1"
    $arsConnection = Connect-QADService -Service $servicename -Proxy
    $arsScheduledTask = Get-QADObject -Identity $task_fullname -IncludedProperties  edsaLastRunTime,edsvaScheduleDescription,edsaLastActionMessage -Connection $arsConnection
    Set-QADObject -identity $task_fullname -objectAttributes @{edsvaExecuteNow=$true} -Connection $arsConnection
    

  • In your line 3, why don't you specify the AR server you want to use in the $servicename variable?  So if you want to run the task on Server1, connect to Server 1 and set the ExecuteNow.  Or maybe am I misunderstanding what you are seeing?

  • That's actually what I am doing. This script is running from ARSServerNumber2 but connecting to ARSServerNumber1 to start the task. When I look in the event log for ARSServerNumber1 I don't see the update to the object. Checking ARSServerNumber2 I DO see the update to the object. Could this be defaulting to the local server because of something I have done ahead of this in the script? I assumed if I told it to use ARSServerNumber1 it would use it. But it is not. One other thing, the scheduled task is also configured to run automatically from ARSServerNumber1 so I thought that might help. It did not.

  • Can you clarify this comment - my interpretation is in the [ ].

    This script is running from ARSServerNumber2 but [I am] connecting to ARSServerNumber1 to start the task.

    To confirm, in your code above, you believe the ARS Connection is being made to server 1?

    It's odd to me that you say the script is configured with an affinity to Server 1 yet you see it running on Server 2.  That's counterintuitive.  

  • I am running scheduled tasks that currently run from two different servers all through one script. Some of them run from server 1 and some of them run from server 2. Server 2 is also a sync server so that was the reason it was picked to do this entire job. Three sync workflows and four scheduled tasks have been combined together to run under one script. {I am] is referencing the line #3 in the script when I say I am connecting to server 1.