How to Initiate a Synchronization
Updated: October 28, 2009
Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2
The Asset Intelligence catalog can be refreshed manually, outside the normal synchronization schedule. A manual refresh is accomplished by using the RequestCatalogUpdate method on the SMS_AIProxy Server WMI Class.
Refresh the Asset Intelligence catalog
-
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
-
Query the SMS Provider for the SMS_AIProxy instance that you want refresh the catalog on.
-
Call the SMS_AIProxy class RequestCatalogUpdate method to run an action on the collection.
Example
The following example method runs the refresh on the provided server.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
public void InitateSync(WqlConnectionManager connection, string serverName) { try { Dictionary<string, object> inParams = new Dictionary<string, object>(); IResultObject classObj = connection.GetClassObject("SMS_AIProxy"); inParams.Add("ProxyName", serverName); Console.WriteLine("Requesting catalog update on server " + serverName); classObj.ExecuteMethod("RequestCatalogUpdate", inParams); } catch (SmsException ex) { Console.WriteLine(String.Format("Failed to request catalog update on server {0}. Error: {1}", serverName, ex.Message)); throw; } }
Function InitateSync(connection, serverName)
On Error Resume Next
Dim classObj: Set classObj = connection.Get("SMS_AIProxy")
Dim inParams: Set inParams = classObj.Methods_("RequestCatalogUpdate").InParameters.SpawnInstance_()
Dim outParams
inParams.Properties_.Item("ProxyName") = serverName
Set outParams = connection.ExecMethod("SMS_AIProxy", "RequestCatalogUpdate", inParams)
If Err.Number <> 0 Then
InitateSync = False
Else
InitateSync = True
End If
On Error Goto 0
End Function
The example method has the following parameters:
| Parameter | Type | Description |
|---|---|---|
|
connection |
Managed: WqlConnectionManager VBScript: SWbemServices |
A valid connection to the provider. |
|
smsCollection |
Managed: String VBScript: String |
Name of the server to run the refresh on. This name maps to the ProxyName property of an SMS_AIProxy instance. |
Compiling the Code
The C# example requires:
Namespaces
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
Robust Programming
For more information about error handling, see About Configuration Manager Errors.
Security
For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.