Udostępnij za pośrednictwem


Jak zastosować niestandardowe ustawienia klienta

W Configuration Manager zastosujesz niestandardowe ustawienia klienta, tworząc wystąpienie klasy Konfiguracja klienta, a następnie wdrażając niestandardowe ustawienia klienta, tworząc wystąpienie SMS_ClientSettingsAssignment klasy i kojarząc wystąpienie klasy Konfiguracja klienta i kolekcję docelową.

Aby zastosować niestandardowe ustawienia klienta

  1. Skonfiguruj połączenie z dostawcą programu SMS.

  2. Utwórz wystąpienie klasy Konfiguracja klienta (na przykład SMS_StateSystemConfig użyte poniżej).

  3. Wypełnij określone niestandardowe ustawienia agenta klienta.

  4. Utwórz wystąpienie SMS_ClientSettingsAssignment klasy.

  5. Wypełnij wartości przypisania ustawień klienta. ClientSettingsID aby zidentyfikować wystąpienie niestandardowych ustawień klienta i CollectionID zidentyfikować kolekcję docelową dla wdrożenia niestandardowych ustawień klienta.

Przykład

Poniższy przykład dotyczy niestandardowych ustawień klienta przez utworzenie wystąpienia klasy Konfiguracja klienta, a następnie wdrożenie niestandardowych ustawień klienta przez utworzenie wystąpienia SMS_ClientSettingsAssignment klasy i skojarzenie wystąpienia klasy Konfiguracja klienta i kolekcji docelowej.

Aby uzyskać informacje na temat wywoływania przykładowego kodu, zobacz Wywoływanie fragmentów kodu Configuration Manager.


public void ApplyCustomClientSettings(WqlConnectionManager connection,string targetCollectionID){
    try
    {
        // Create a new instance of specific client agent settings (in this case State Messaging)
        IResultObject newCustomClientAgentSettings = connection.CreateEmbeddedObjectInstance("SMS_StateSystemConfig");

        // Populate specific custom client agent settings
        newCustomClientAgentSettings["BulkSendInterval"].IntegerValue = 120;
        newCustomClientAgentSettings["BulkSendIntervalHigh"].IntegerValue = 5;
        newCustomClientAgentSettings["BulkSendIntervalLow"].IntegerValue = 30;

        // Create a new array list to hold the custom client agent settings object(s)
        List<IResultObject> tempAgentConfigurationsArray = new List<IResultObject>();

        // Add the custom client agent settings embedded object to the local array list
        tempAgentConfigurationsArray.Add(newCustomClientAgentSettings);

        // Create a new instance of SMS_ClientSettings
        IResultObject newClientSettings = connection.CreateInstance("SMS_ClientSettings");

        // Populate the client agent settings
        newClientSettings["Name"].StringValue = "Custom State Messaging Configuration";

        // Add the array of custom client agent settinsg object(s) to the AgentConfigurations property
        newClientSettings.SetArrayItems("AgentConfigurations", tempAgentConfigurationsArray);

        // Save and retrieve the new instance of SMS_ClientSettings
        newClientSettings.Put();
        newClientSettings.Get();

        // Get the SettingsID value of the new SMS_ClientSettings instance
        Int32 SettingsID = newClientSettings["SettingsID"].IntegerValue;

        // Create a new instance of SMS_ClientSettingsAssignment
        IResultObject newClientSettingsAssignment = connection.CreateInstance("SMS_ClientSettingsAssignment");

        // Populate the client settings assignment values
        // ClientSettingsID to identify the custom client settings
        // CollectionID to identify the target collection for the custom client settings
        newClientSettingsAssignment["ClientSettingsID"].IntegerValue = SettingsID;
        newClientSettingsAssignment["CollectionID"].StringValue = targetCollectionID;

        // Save the new instance of the client settings assignment.
        newClientSettingsAssignment.Put();
    }
    catch (SmsException ex)
    {
        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);
    }
}

Przykładowa metoda ma następujące parametry:

Parametr Wpisać Opis
connection -Zarządzane: WqlConnectionManager Prawidłowe połączenie z dostawcą programu SMS.
targetCollectionID -Zarządzane: String Kolekcja docelowa wdrożenia niestandardowych ustawień klienta.

Kompilowanie kodu

Ten przykład języka C# wymaga:

Obszary nazw

System

System.collections.generic

System.text

Microsoft. ConfigurationManagement.ManagementProvider

Microsoft. ConfigurationManagement.ManagementProvider.WqlQueryEngine

Zestawu

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Niezawodne programowanie

Aby uzyskać więcej informacji na temat obsługi błędów, zobacz Informacje o błędach Configuration Manager.

zabezpieczenia .NET Framework

Aby uzyskać więcej informacji na temat zabezpieczania aplikacji Configuration Manager, zobacz Configuration Manager administracja oparta na rolach.

Zobacz też

zestaw SDK Configuration Manager
SMS_ClientSettingsAssignment Server WMI Class