This article is a follow-on to my previous post, Cool Tool: New Command Line Utility to Start a Runbook , where I talked about using the web service to quickly start a runbook with named parameters. Now it’s time to put that into action!
Orchestrator administrators know that Orchestrator is not built to be a scheduling tool. Sure, it can use a “Monitor Date/Time” activity to actively start new runbook jobs on a regular basis. The problem is that it’s a bit clunky . Let’s say I wanted to have a runbook run every Monday at 10:15pm. Here’s how would I do that:
The screen shots of steps 1 through 4 are below:
Now this process will give me the results I needed. The activities after the Check Schedule activity will run every Monday at 10:15 PM. So here’s what’s clunky about that:
So now do you see why we always say that Orchestrator *can* do scheduled runbooks, but it’s not designed to be a scheduling tool? Now that you know what *not* to do, here’s an easy way to do scheduling using something as simple as Windows Task Scheduler. It’s installed on every Windows Server, so it’s not like you have to go buy something else. However, if you already have some enterprise scheduling tool, you can transfer this knowledge to that and get the same benefit.
First of all, I opened Task Scheduler and created a new folder called System Center 2012 Orchestrator. You might just call it Orchestrator, but the marketing / branding folks around here will beat me with a wooden (compostable) spoon if I don’t use the correct term.
Then you just right-click and select Create Task to open the Create Task form.
In the form, enter a name and description, and set the task to Run whether a user is logged on or not (since it an automated thing running a web service).
Click on the Triggers tab and then click New . Let’s assume I’m going to keep my Mondays at 10:15 PM schedule. Here’s what that would look like:
As you can see, there are some options that I can set here that I couldn’t even replicate in the runbook without some complex PowerShell script or something, like time zone synchronization, random delays, expiration, and so on. When I click OK, this schedule is saved and I could actually add a number of schedules here if I wanted to mix and match monthly with daily or some other combination.
Click on the Actions tab – this is where the runbook is triggered from. Click New and the New Action form appears. I select Start a Program and then enter the path to my SCOJobRunner.exe utility, and the command line arguments I need to start the runbook. If I’m running this on the same server as my Orchestrator Web Service, I don’t need to specify the web server or credentials (credentials are already specified in the task definition). All I need to specify is the runbook ID or path and the parameters needed (if any). For example:
-RunbookPath:"\Scheduled Runbooks\Run My Script" -Parameters:"Path='Path 1';Other Text='some other text here'"
Noticed how I cleverly used a folder named “Scheduled Runbooks”? This tells me (or anyone else using the Runbook Designer or Orchestration Console) that all the runbooks in the folder are run on a schedule.
Clicking OK brings me back to the Actions tab, where I see I can add even more actions (such as if I want to run multiple runbooks at the same scheduled time).
Now click on the Conditions tab. Here I can specify conditions (go figure) where the task will run or not. Since this is a server, I can generally leave all the settings here alone. However, if you happen to be doing a demo of Orchestrator on a laptop, you should uncheck those AC power and battery options.
Finally, click the Settings tab. Here you can define some additional options to your needs. For me, I’ll leave the defaults.
Clicking OK causes a prompt for the credentials for running this task. Enter those and click OK and you’re back at the main Task Scheduler page and you can see the new task there.
So now if you want to add more scheduled runbooks, you just add them the same way, and now you have a convenient list of runbooks and their start times you can access, and it even shows you the next time it’s going to run. By clicking on the History tab below, you can even see a list of all the times the task ran and the results.
The benefits to this approach, rather than creating Monitor runbooks, are:
So hopefully this article has taught you something about scheduling in Orchestrator, a little about Monitors (more on that subject later), and a good use for the command line tool I mentioned in the previous post.
Download the zip file containing the utility here: SCO Job Runner - Command Line Utility
Download the source code to the utility here: http://orchestrator.codeplex.com/SourceControl/list/changesets
Until next time!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.