Home / SCSM / Change the AD Connector Sync Frequency in Service Manager 2012 R2

Change the AD Connector Sync Frequency in Service Manager 2012 R2

Even though with SCSM 2012 R2 UR6, AD connector for Service Manager now comes with an option where the time for the AD sync can be changed; it still syncs every 24 hours which cannot be changed out the box. This is  best practice and is recommended in most production cases but there are some cases (POC, Demo, etc.) where you would want to change the AD sync time frequency to less than 24 hours. This can be done by some PowerShell magic in Service Manager.

Below are the steps you can follow to change this setting in Service Manager.

1. Load the SCSM SDK assemblies using the powershell cmdlet below. You would need to point it to where your Service Manager installation folder is.

PS D:\> [Reflection.Assembly]::LoadFile(“D:\Program Files\Microsoft System Center 2012 R2\Service Manager\SDK Binaries\Microsoft.EnterpriseManagement.Core.dll”)

SCSM SDK Assembly

PS D:\> [Reflection.Assembly]::LoadFile(“D:\Program Files\Microsoft System Center 2012 R2\Service Manager\SDK Binaries\Microsoft.EnterpriseManagement.ServiceManager.dll”)

SCSM SDK Assembly 2

2. After the assemblies are loaded in the powershell, we connect the Management Group of the Service Manager. Since I am executing the powershell on the machine hosting the SDK Service, I can connect to the “LocalHost”. This command will have no output and we store the command in a variable.

PS D:\> $SMMG = New-Object Microsoft.EnterpriseManagement.ServiceManagementGroup
“localhost”

ManagementGroup

3.Let’s store the AD connector we want to change in the variable $SMAD as well.

PS D:\> $SMAD = $SMMG.ConnectorFramework.GetConnectors() | where {$_.DisplayName
-eq ‘Active Directory Connector’}

ADVariable

If we look at the output of the $SMAD variable, we are able to view the information about the AD connector. However, the DisplayName for the AD connector might be different for your SCSM setup, so   enter that accordingly.

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

PS D:\> $EnumSyncType = $SMMG.EntityTypes.GetEnumerations() | where {$_.Name -eq
‘SyncTypeEnum’}

SyncTypeEnum

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

PS D:\> $SyncTypes = $SMMG.EntityTypes.GetChildEnumerations($EnumSyncType.Id, [Microsoft.EnterpriseManagement.Common.TraversalDepth]::OneLevel)

SyncTypes

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 hour.

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

PS D:\> $SMAD.ConnectorObject.Item($null, “SyncType”).Value = $SyncTypes | where{$_.Name -eq ‘SyncTypeEnum.Hours’}
PS D:\> $SMAD.ConnectorObject.Item($null, “SyncInterval”).Value = 1
PS D:\> $SMAD.ConnectorObject.Commit()
PS D:\> $SMMG.LinkingFramework.UpdateDataSource($SMAD.ConnectorObject.Id)
ChangeSyncInterval

And if we run the PS D:\> Get-SCSMConnector | fl command we should be able to see the time changed on the AD connector in Service Manager.

SyncTimeChanged

Hope this helps. 🙂

About prabthind

Prab Thind is currently working as Senior Consultant at Infront Consulting Group. Works primarily with Azure and System Center. Prab holds multiple Microsoft Certifications in Azure and Private Cloud.

Leave a Reply

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

*