How to change SCSM connector schedule

Have you ever wonder how to change SCSM connector schedule?

System Center Service Manager is relatively young product in System Center family.
Functionality is not so good like in SCCM or SCOM and for some tasks we need to use Powershell.
The critical functionality which is not available in SCSM GUI is adjustment of connector schedule.

Todays function gives a possibility to change SCSM connector schedule which is already created.
Below script is adjusted to change connector schedule to every one hour.
Standard SCSM Powershell commands does not have possibility to perform action like this.
Script use SDK assemblies which are provided with System Center Service Manager installation.

If you want to adjust schedule for your needs, you must adjust below lines

$connector.ConnectorObject.Item($null,"SyncType").Value = $allSyncTypesEnums | ? {$_.Name -eq "SyncTypeEnum.Hours"}
$connector.ConnectorObject.Item($null,"SyncInterval").Value = 1
$connector.ConnectorObject.Item($null,"SyncTime").Value = ([datetime]"03.06.1970 01:00").ToUniversalTime()

Final script

function Update-SCSMConnector {
    # Mandatory Display Name of the changed connector
    [CmdletBinding()]
    param(
        [Parameter(Mandatory=$True)]
        [string] $ConnectorName
    )

    #SDK Assemblies needed to update connector
    $SMDIR    = (Get-ItemProperty "hklm:\SOFTWARE\Microsoft\System Center\2010\Service Manager\Setup\").InstallDirectory
    $SMSDKDIR = "${SMDIR}\SDK Binaries"
    $SMDLL    = "${SMSDKDIR}\Microsoft.EnterpriseManagement.Core.dll"
    $SMADDDLL = "${SMSDKDIR}\Microsoft.EnterpriseManagement.ServiceManager.dll"

    [reflection.assembly]::LoadFile($SMDLL) | out-null
    [reflection.assembly]::LoadFile($SMADDDLL) | out-null

    $ServiceManagementGroup = new-object Microsoft.EnterpriseManagement.ServiceManagementGroup "localhost"

    # Get all SyncTypeEnum enums
    $syncTypeEnum =  $ServiceManagementGroup.EntityTypes.GetEnumerations() | ? {$_.Name -eq "SyncTypeEnum"}
    $allSyncTypesEnums = $ServiceManagementGroup.EntityTypes.GetChildEnumerations($syncTypeEnum.Id, [Microsoft.EnterpriseManagement.Common.TraversalDepth]::Recursive)

    # Get connector by DisplayName (as displayed in SCSM console)
    $connectors = $ServiceManagementGroup.ConnectorFramework.GetConnectors() | ? {$_.DisplayName -eq $ConnectorName}
    foreach($connector in $connectors)
    {
        Write-Host $connector.DisplayName
        $connector.ConnectorObject.Item($null,"SyncType").Value = $allSyncTypesEnums | ? {$_.Name -eq "SyncTypeEnum.Hours"}
        $connector.ConnectorObject.Item($null,"SyncInterval").Value = 1
        $connector.ConnectorObject.Item($null,"SyncTime").Value = ([datetime]"03.06.1970 01:00").ToUniversalTime()

        Write-Host "Updating...."
        $connector.ConnectorObject.Commit()
        $ServiceManagementGroup.LinkingFramework.UpdateDataSource($connector.ConnectorObject.Id)
        Write-Host "Complete"
    }    
}

I hope it will be usefull for some of you 🙂
Enjoy!

Leave a Reply

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

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