Change the AD Connector Sync Frequency in Service Manager 2012

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

 

One thought on “Change the AD Connector Sync Frequency in Service Manager 2012

  1. Davis Valdés

    Hi team, I’m trying to set my SCSM 2012 SP1 AD Connector to run every 4 hours. But when i’m running the cmdlet i get this error at the point 6.

    ——————————————-

    ——————————————-

    PS C:\> $SyncTypes | Select Name

    Name
    —-
    SyncTypeEnum.Minutes
    SyncTypeEnum.Monthly
    SyncTypeEnum.None
    SyncTypeEnum.Hours
    SyncTypeEnum.Daily
    SyncTypeEnum.Weekly

    PS C:\> $SMAD.ConnectorObject.Item($null, “SyncType”).Value = $SyncTypes | where{$_.Name -eq ‘SyncTypeEnum.Hours’}
    You cannot call a method on a null-valued expression.
    At line:1 char:1
    + $SMAD.ConnectorObject.Item($null, “SyncType”).Value = $SyncTypes | where{$_.Name …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
        + FullyQualifiedErrorId : InvokeMethodOnNull

    ——————————————-

    ——————————————-

    I appreciate the help

    DV

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.