Change Service Manager Connector Schedule

I’ve now heard from multiple customers that they want to better control when their Service Manager connectors are running. For whatever reason, Microsoft didn’t really include a UI to control the schedule of most connectors, except for the SCCM and SCOM connectors. What if you want to control the schedule for the Active Directory connector, for example?

You have the following options:

Method 1: Initiate the synchronization using PowerShell

SCSM has a rich PowerShell API. The cmd-let Start-SCSMConnector allows you to initiate the synchronization.
On my test machine, I have a connector called “AD, all users”. When I start the Service Manager Shell and execute the command


I get a list like this:

The command

Get-SCSMConnector | fl

will show some more information, including the schedule (sync time, type and interval):

As you can see from the screenshot above, the AD connector will synchronize automatically every day at 2:00 AM
Now to start connectors using PowerShell immediately, you just need to get one or more connectors into a variable and pipe it to the Start-SCSMConnector cmd-let. In my case I just want to start this single connector but you could modify the line to include more connectors in the WHERE-OBJECT:

You could write this in one line, of course but for better readability I used a variable.

After you’ve executed the command, you will see the connector will start synchronizing after a minute or so.

This is an easy way to start the connectors on your own schedule (using the task scheduler) or initiate synchronization at the end of an Orchestrator runbook. For example: consider an Orchestrator runbook which creates a user in the domain, executes a sync on the domain controllers and immediately start the connector for Service Manager afterwards.

Method 2: Change the synchronization schedule using PowerShell

Update: After fixing the last line in the script, the code works as expected. To be clear, MS may not support this, so I recommend you test this in a lab environment before you go ahead and use it.

Loading SDK Assemblies

To change the schedule on the connector itself, a little SDK magic is necessary. To access the SDK from PowerShell we need to load the SDK assembly. Type the following commands (assuming your service manager install directory is the default directory):

[Reflection.Assembly]::LoadFile("C:Program FilesMicrosoft System Center 2012Service ManagerSDK BinariesMicrosoft.EnterpriseManagement.Core.dll")
[Reflection.Assembly]::LoadFile("C:Program FilesMicrosoft System Center 2012Service ManagerSDK BinariesMicrosoft.EnterpriseManagement.ServiceManager.dll")
Connecting to the Management Group
$MG = New-Object Microsoft.EnterpriseManagement.ServiceManagementGroup “localhost”

Since I’m executing the PowerShell on the machine hosting the SDK service, I can connect to “localhost”. The above command has no output.

Get the AD Connector using the SDK

As we did in the example above, let’s store the AD connector we want to change in the variable $ad:

$ad = $MG.ConnectorFramework.GetConnectors() | where {$_.DisplayName -eq 'AD, all users'}

Note that the connector object from the SDK looks quite different compared to the one we used in the above PowerShell example.

Get the Enum from the SDK

Now let’s get the Enum with the Name “SyncTypeEnum”:

$EnumSyncType = $MG.EntityTypes.GetEnumerations() | where {$_.Name -eq 'SyncTypeEnum'}

The next command will get all child elements for the SyncType enumeration we gathered above:

$SyncTypes = $MG.EntityTypes.GetChildEnumerations($EnumSyncType.Id, [Microsoft.EnterpriseManagement.Common.TraversalDepth]::OneLevel)

If you select all the names from the $SyncTypes array, you’ll see the possible values. By default, the AD connector syncs Daily, we want to change that to every 2 hours.

Change the Sync Type and Interval

To change the SyncType and SyncInterval values using the SDK, type:

$ad.ConnectorObject.Item($null, "SyncType").Value = $SyncTypes | where {$_.Name -eq 'SyncTypeEnum.Hours'}
$ad.ConnectorObject.Item($null, "SyncInterval").Value = 2

The last two lines are used to commit and save the changes to the management group.

As you can see, we’ve changed the connector schedule to every two hours.

Compared to method 1, this is much more complicated, geeky and is prone to error. In the spirit of KISS (keep it simple and stupid) I recommend method 1. Much easier to setup and change.

Leave a Reply