Udostępnij za pośrednictwem


Jak skonfigurować ustawienia narzędzi zdalnych

W Configuration Manager ustawisz ustawienia agenta klienta narzędzi zdalnych, modyfikując wymagane ustawienia pliku kontroli lokacji.

Aby skonfigurować ustawienia narzędzi zdalnych

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

  2. Nawiązywanie połączenia z sekcją Agent klienta narzędzi zdalnych w pliku kontroli lokacji SMS_SCI_ClientComp przy użyciu klasy .

  3. Przeprowadź pętlę przez tablicę dostępnych właściwości, wprowadzając zmiany zgodnie z potrzebami.

  4. Zatwierdź zmiany w pliku kontroli lokacji.

Przykład

Poniższy przykład ustawia ustawienia agenta klienta narzędzi zdalnych przy użyciu SMS_SCI_ClientComp klasy w celu nawiązania połączenia z plikiem kontroli lokacji i zmiany właściwości.

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


Sub ConfigureRemoteControlClientAgentSettings(swbemServices,            _  
                                              swbemContext,             _  
                                              siteCode,                 _  
                                              enableDisableClientAgent, _  
                                              newPermissionRequired,    _   
                                              newVisibleSignal,         _  
                                              newAudibleSignal)  

    ' Load the site control file and get the remote tools client agent section.  
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Refresh", , , swbemContext  

    Query = "SELECT * FROM SMS_SCI_ClientComp " & _  
    "WHERE ClientComponentName = 'Remote Control' " & _  
    "AND SiteCode = '" & siteCode & "'"            

    Set SCIComponentSet = swbemServices.ExecQuery(Query, ,wbemFlagForwardOnly Or wbemFlagReturnImmediately, swbemContext)  

    ' Only one instance is returned from the query.  
    For Each SCIComponent In SCIComponentSet  

        ' Set the client agent by setting the Flags value to 0 or 1 using the enableDisableClientAgent variable.  
        wscript.echo " "  
        wscript.echo "Remote Control Agent"  
        wscript.echo "Current value " &  SCIComponent.Flags  

        ' Modify the value.                  
        SCIComponent.Flags = enableDisableClientAgent  
        wscript.echo "New value " & enableDisableClientAgent  

        ' Loop through the array of embedded SMS_EmbeddedProperty instances.  
        For Each vProperty In SCIComponent.Props  

            ' Setting: Permission Required  
            If vProperty.PropertyName = "Permission Required" Then  
                wscript.echo " "  
                wscript.echo vProperty.PropertyName  
                wscript.echo "Current value " &  vProperty.Value                 

                'Modify the value.  
                vProperty.Value = newPermissionRequired  
                wscript.echo "New value " & newPermissionRequired  
            End If  

            ' Setting: Visible Signal  
            If vProperty.PropertyName = "Visible Signal" Then  
                wscript.echo " "  
                wscript.echo vProperty.PropertyName  
                wscript.echo "Current value " &  vProperty.Value                 

                ' Modify the value.  
                vProperty.Value = newVisibleSignal  
                wscript.echo "New value " & newVisibleSignal  
            End If  

            ' Setting: Audible Signal  
            If vProperty.PropertyName = "Audible Signal" Then  
                wscript.echo " "  
                wscript.echo vProperty.PropertyName  
                wscript.echo "Current value " &  vProperty.Value                 

                ' Modify the value.  
                vProperty.Value = newAudibleSignal  
                wscript.echo "New value " & newAudibleSignal  
            End If  

        Next     

             ' Update the component in your copy of the site control file. Get the path  
             ' to the updated object, which could be used later to retrieve the instance.  
             Set SCICompPath = SCIComponent.Put_(wbemChangeFlagUpdateOnly, swbemContext)  
    Next  

    'Commit the change to the actual site control file.  
    Set InParams = swbemServices.Get("SMS_SiteControlFile").Methods_("CommitSCF").InParameters.SpawnInstance_  
    InParams.SiteCode = siteCode  
    swbemServices.ExecMethod "SMS_SiteControlFile", "CommitSCF", InParams, , swbemContext  

End Sub  


public void ConfigureRemoteControlClientAgentSettings(WqlConnectionManager connection,  
                                                      string siteCode,  
                                                      string enableDisableRemoteControlClientAgent,  
                                                      string newPermissionRequired,  
                                                      string newVisibleSignal,  
                                                      string newAudibleSignal)  
{  
    try  
    {  
        IResultObject siteDefinition = connection.GetInstance(@"SMS_SCI_ClientComp.FileType=1,ItemType='Client Component',SiteCode='" + siteCode + "',ItemName='Remote Control'");  

        // Setting: Enable Remote Control Client Agent  
        // Set Remote Control client agent by setting flags value to  0 or 1 using the EnableDisableRemoteControlClientAgent variable.   
        Console.WriteLine();  
        Console.WriteLine("Remote Control Client Agent");  
        Console.WriteLine("Current value: " + siteDefinition["Flags"].StringValue);  

        // Change value using the enableDisableRemoteControlClientAgent value passed in.   
        siteDefinition["Flags"].StringValue = enableDisableRemoteControlClientAgent;  
        Console.WriteLine("New value    : " + enableDisableRemoteControlClientAgent);  

        foreach (KeyValuePair<string, IResultObject> kvp in siteDefinition.EmbeddedProperties)  
        {  

            // Create temporary working copy of embedded properties.  
            Dictionary<string, IResultObject> embeddedProperties = siteDefinition.EmbeddedProperties;  

            // Setting: Permission Required.  
            if (kvp.Value.PropertyList["PropertyName"] == "Permission Required")  
            {  
                Console.WriteLine();  
                Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
                Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue);  

                // Change value using the newPermissionRequired value passed in.   
                embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue = newPermissionRequired;  
                Console.WriteLine("New value    : " + newPermissionRequired);  
            }  

            // Setting: Visible Signal.  
            if (kvp.Value.PropertyList["PropertyName"] == "Visible Signal")  
            {  
                Console.WriteLine();  
                Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
                Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue);  

                // Change value using the newScanSchedule value passed in.   
                embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue = newVisibleSignal;  
                Console.WriteLine("New value    : " + newVisibleSignal);  
            }  

            // Setting: Audible Signal.  
            if (kvp.Value.PropertyList["PropertyName"] == "Audible Signal")  
            {  
                Console.WriteLine();  
                Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
                Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue);  

                // Change value using the newAudibleSignal value passed in.   
                embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue = newAudibleSignal;  
                Console.WriteLine("New value    : " + newAudibleSignal);  
            }  

            // Store the settings that have changed.  
            siteDefinition.EmbeddedProperties = embeddedProperties;  
        }  

        // Save the settings.  
        siteDefinition.Put();  

    }  
    catch (SmsException ex)  
    {  
        Console.WriteLine("Failed. Error: " + ex.InnerException.Message);  
        throw;  
    }  
}  

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

Parametr Wpisać Opis
connection

swbemServices
-Zarządzane: WqlConnectionManager
- VBScript: SWbemServices
Prawidłowe połączenie z dostawcą programu SMS.
swbemContext -Vbscript: SWbemContext Prawidłowy obiekt kontekstu. Aby uzyskać więcej informacji, zobacz How to Add a Configuration Manager Context Qualifier by Using WMI (Jak dodać kwalifikator kontekstu Configuration Manager przy użyciu usługi WMI).
siteCode -Zarządzane: String
-Vbscript: String
Kod witryny.
-Zarządzane: enableDisableRemoteControlClientAgent
-Vbscript: enableDisableClientAgent
-Zarządzane: String
-Vbscript: String
Określa, czy agent klienta narzędzi zdalnych jest włączony, czy wyłączony.

0 — wyłączone

1 — włączone
newPermissionRequired -Zarządzane: String
-Vbscript: String
Określa, czy do zdalnego sterowania jest wymagane uprawnienie.

0 — nie jest wymagane

1 — wymagane
newVisibleSignal -Zarządzane: String
-Vbscript: String
Określa, czy widoczny sygnał jest włączony, czy wyłączony.

0 — wyłączone

1 — włączone
newAudibleSignal -Zarządzane: String
-Vbscript: String
Określa, czy sygnał dźwiękowy jest włączony, czy wyłączony.

0 — wyłączone

1 — włączone

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 Configuration Manager Software Development Kit
Informacje o pliku kontrolki lokacji Configuration Manager
Jak odczytywać i zapisywać w pliku kontroli lokacji Configuration Manager przy użyciu kodu zarządzanego
Jak odczytywać i zapisywać w pliku kontroli lokacji Configuration Manager przy użyciu usługi WMI
SMS_SCI_Component Server WMI Class