To Initiate a One-time Membership Evaluation

  1. Set up a connection to the SMS Provider.

  2. Get the specific collection instance by using the collection ID provided.

  3. Refresh the collection membership using the RequestRefresh Method in Class SMS_Collection method.

Example

The following example method refreshes the collection membership for a specific collection.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Visual Basic Script  Copy Code
Sub RefreshCollection(connection, collectionID)	Dim collection	Set collection = connection.Get("SMS_Collection.CollectionID='" & collectionID & "'")	Call collection.RequestRefresh()End Sub
C#  Copy Code
public void RefreshCollection(WqlConnectionManager connection, string collectionID){ IResultObject collection = connection.GetInstance(string.Format("SMS_Collection.CollectionID='{0}'", collectionID)); collection.ExecuteMethod("RequestRefresh", null);}

The example method has the following parameters:

Parameter Type Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

collectionID

  • Managed: String

  • VBScript: String

Unique auto-generated ID containing eight characters. For more information, see the CollectionID property of SMS_Collection Server WMI Class.

Compiling the Code

The C# example requires:

Namespaces

System

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

mscorlib

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

See Also