Set User Profile Import Schedule

Posted on Posted in SharePoint 2007, STSADM Commands

Update 9/18/2007: I’ve modified this command so that it no longer manipulates the database directly. The content below has been updated to reflect the changes.

This particular command which I called gl-setuserprofileimportschedule, really drove me nuts. As far as I could find there is no way to set this information using any Microsoft provided public API. If you disassemble the code that is doing this you’ll find lots of great classes that allow programmatic manipulation of this as well as other SSP and Profile related configurations – unfortunately those classes are all marked internal so we can’t use them easily.

The two main ones are UserProfileApplication and SharedResourcesProvider. Microsoft uses these two classes for most of the more complex configuration settings. Because manipulating the database directly is not supported by Microsoft I chose to rewrite this command from it’s original incarnation so that I now utilize the internal classes, methods, and properties that Microsoft is using when setting the schedule via the browser. Keep in mind that this approach is also not supported by Microsoft but it is their recommended approach over manipulating the database and is generally less frowned upon.

The syntax of the command can be seen below (note that if you were using this command prior to 9/18/2007 then the syntax has changed):

C:\>stsadm -help gl-setuserprofileimportschedule

stsadm -o gl-setuserprofileimportschedule


Sets the profile import schedule.

Parameters:
        -sspname <SSP name>
        -type <incremental|full>
        -occurrence <daily|weekly|monthly>
        -hour <hour to run (0-23)>
        [-day <the day to run if monthly is specified>]
        [-dayofweek <the day of week to run if weekly is specified (sunday|monday|tuesday|wednesday|thursday|friday|saturday)>]
        [-enabled <true|false> (default is true)]
        [-runjob]

The following table summarizes the command and its various parameters:

Command Name Availability Build Date
gl-setuserprofileimportschedule MOSS 2007 Release: 8/9/2007

Updated: 8/14/2008
Parameter Name Short Form Required Description Example Usage
sspname ssp No The name of the SSP that the user profiles are associated with.  If omitted the default SSP will be used. -sspname SSP1

-ssp SSP1

type t Yes The type of schedule to set.  Valid values are "incremental" and "full". -type full

-t full

occurrence oc Yes Specifies how frequently the import should occur.  Valid values are "daily", "weekly", and "monthly". -occurrence daily

-oc monthly

hour   Yes The hour in which to run the import job.  This should be an integer between 0 and 23 (where 0 is 12:00am and 23 is 11:00pm). -hour 22
day   No, unless occurrence is monthly The day of the month to run the import job.  Valid values are between 1 and 31. -day 1
dayofweek   No, unless occurrence is weekly The day of the week to run the import job.  Valid values are "sunday", "monday", "tuesday", "wednesday", "thursday", and "saturday". -dayofweek saturday
enabled   No "true" to enable the import schedule, "false" to disable it.  If not specified then the import schedule will be enabled. -enabled true
runjob run No If specified then the import job will be immediately executed after setting the schedule. -runjob

-run

Here’s an example of how to set the full import schedule to every Saturday at 3:00AM:

stsadm –o gl-setuserprofileimportschedule –sspname SSP1 -type full -occurrence weekly -hour 3 -dayofweek Saturday

Please note that because this command uses internal only classes, methods, and properties directly it could, according to Microsoft, put your environment into an un-supported state (though this is Microsoft’s recommended approach over directly manipulating the database). Please make sure you understand what the command is doing and what your support options with Microsoft are.

5 thoughts on “Set User Profile Import Schedule

  1. Note that I did recently stumble upon the enumssp command which could be used to get the configuration database name. Basically just parse the resultant xml and use that rather than requiring the user to provide the server name and database. If I’m feeling up to it I’ll modify my code to use this command (I can’t simply do what Microsoft is doing programmatically as they are using internal classes again – mainly SspUtility and SharedResourceProvider).

  2. It would be useful if you changed the mandatoryness (if that’s a word) of the arguments such that you could just use:

    stsadm -o gl-setuserprofileimportschedule -sspname %NAME% -runjob

    i.e. Just kick off a job now without altering the schedule.

  3. I’d thought about that but instead I decided to create a separate command, gl-runprofileimport. Mainly because I wanted to be able to handle the user and distribution list imports separately and it was cleaner to do this as a separate command.

  4. Chris – I looked into this a while ago and decided not to pursue it for various reasons (if I recall some of the methods/classes were marked internal and I didn’t want to use reflection).

Leave a Reply

Your email address will not be published. Required fields are marked *

*