Partilhar via


How to Refresh the Compliance State

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

In Microsoft System Center Configuration Manager 2007, you refresh the client compliance state by creating an instance of the UpdatesStore COM class and by using the RefreshServerComplianceState method. This causes the client to resend a full compliance report to the Configuration Manager 2007 server.

To refresh the server compliance state

  1. Create an UpdatesStore instance by using the UpdatesStore COM class.

  2. Refresh the server compliance state by using the RefreshServerComplianceState method.

Example

The following example method shows how to refresh the server compliance state by creating an instance of the UpdatesStore COM class. This causes the client to resend compliance status to the Configuration Manager server.

For information about calling the sample code, see How to Call Configuration Manager COM Automation Objects

Sub RefreshServerComplianceState()

    ' Initialize the UpdatesStore variable.
    dim newCCMUpdatesStore 
    
    ' Create the COM object.
    set newCCMUpdatesStore = CreateObject ("Microsoft.CCM.UpdatesStore")

    ' Refresh the server compliance state by running the RefreshServerComplianceState method.
    newCCMUpdatesStore.RefreshServerComplianceState
    
    ' Output success message.
    wscript.echo "Ran RefreshServerComplianceState."

End Sub
public void RefreshServerComplianceState()
{
    try
    {
        // Create UpdatesStore instance.
        UpdatesStoreLib.CcmUpdatesStoreAutomationClass newCCMUpdatesStore = new UpdatesStoreLib.CcmUpdatesStoreAutomationClass();

        // Refresh the server compliance state by running the RefreshServerComplianceState method.
        newCCMUpdatesStore.RefreshServerComplianceState();

        // Output success message.
        Console.WriteLine("Ran RefreshServerComplianceState.");
    }

    catch (COMException ex)
    {
        Console.WriteLine("Failed to run RefreshServerComplianceState method. Error: " + ex.Message);
        throw;
    }

}

Compiling the Code

This C# example requires:

Namespaces

System

System.Runtime.InteropServices

UpdatesStoreLib COM Automation Library

COM Automation

The reference that is needed for early binding is UpdatesStore 1.0 Type Library. This creates a type library reference named UpdatesStoreLib.

Robust Programming

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

Security

For more information about securing Configuration Manager applications, see Securing Configuration Manager Applications.

See Also

Concepts

System Center Configuration Manager Software Development Kit
Configuration Manager Software Updates
About Software Updates Client
Software Updates Client COM Automation Classes
ICCMUpdatesStore::RefreshServerComplianceState