A Simple MIIS Scheduler

OK now it’s time to get into the scheduling script I wrote for MIIS.

At some point I’d like to have a go at rewriting this as a .NET service (addendum: this is now done, see here), but VBScript was where I started, mostly because of the examples in the Developer’s Reference.

I’m not going to post the entire script (sorry) because it’s too specific to the environment it was created for, but I’ll give some ideas and code snippets that may be useful.

The Task Queue

The first thing my scheduler needs is a queue. I created this as a SQL table to avoid file locking problems, and to allow jobs to be inserted from other sources. (In particular the client app I wrote ‘MiisApp’.)

The following example Queue shows a Delta Import from SQL, followed by an Export to AD. There are various other steps included that run things outside of MIIS such as a SQL DTS package. The final instruction stops the script.

Task Name Profile Priority
RunDTS CreateDeltaTables 1
RunProfile SQL_People Delta Import and Delta Sync 2
RunSub CheckADExports 3
RunProfile AD Export 4
RunSub PostADExportTasks 5
RunProfile AD Delta Import and Delta Sync 6
Stop 99

RunDTS

A sub that runs the named DTS package in SQL. More on this in another post.

RunProfile

A simple sub-routine that executes the Profile in MIIS. There’s a perfectly good example in the Developer’s Reference, so I would suggest starting there.

RunSub

The RunSub subroutine was really just a way to get around VBScript not being able to use a variable value as a subroutine name – i.e. I couldn’t just pass it the value “CheckADExports” and have it run that sub. It’s basically just a Case statement where I list all my possible subroutines that may be found in the Queue:

Select Case LCase(Name)
  Case “checkadexports”
  CheckADExports

  Case “postadexporttasks”
  PostADExportTasks

End Select

Processing the Queue

The main body of the script is fairly simple. It keeps looping until it gets to a STOP command in the queue (which, by the way, you could insert using a Scheduled Task if you want the syncs to stop overnight). Meanwhile it runs all queued commands and, if the queue is empty, it inserts a default cycle. I also like to add ten minutes of sleep at the end, so the server is not cycling continuously, and I have a window if I need to jump on and do anything manually.

I won’t include all the subroutines in this post, but follow the links if you want to see them.

Do While Not STOP

  If JobInQueue(Task, Name) Then

  If LCase(Task) = “stop” Then

 WriteLog “Stopping.”

STOP = TRUE

Else

 RunQueuedJob Task, Name

 End If

 Else ‘No queued job – insert jobs as listed in the DefaultCycle array

 For i = 1 To Ubound(DefaultCycle,1)

  AddToQueue DefaultCycle(i), i

  Next

  AddToQueue “RunSub,sleep,”, 99

Loop

For a list of all the sections of the scheduling script that I’ve posted see the jobRunner.vbs section on the Code Snippets page.

1 Reply to “A Simple MIIS Scheduler”

  1. Hi Carol,

    Nice example how you can do things more advanced within MIIS, but do you know the “IM Sequencer” (http://www.traxionsolutions.com/imsequencer), this application is specifically for scheduling, sequencing and reporting management agents within MIIS.

    Keep up the good work,

    Regards Paul Wijntjes

Comments are closed.