Edit

Share via


How to Initiate a One-time Membership Evaluation for a Collection

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 the SMS_Collection class.

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.

Sub RefreshCollection(connection, collectionID)    Dim collection    Set collection = connection.Get("SMS_Collection.CollectionID='" & collectionID & "'")    Call collection.RequestRefresh()End Sub  
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

SMS_Collection Server WMI Class