Sdílet prostřednictvím


Konfigurace inzerovaných programů distribuce softwaru – Nastavení klientského agenta

V Configuration Manager udržuje řídicí soubor lokality konfiguraci lokality. Toto téma ukazuje, jak nakonfigurovat programy s inzerovanými distribucemi softwaru nastavení klientského agenta v řídicím souboru lokality. Další informace o čtení z řídicího souboru webu a zápisu do řídicího souboru webu najdete v tématu Informace o řídicím souboru webu.

Upozornění

Před použitím tříd poskytovatele serveru SMS ke změně konfigurace lokality byste měli mít zkušenosti se správou konfigurace lokality. Měli byste být opatrní nebo se zcela vyhnout používání SMS_SCI_FileDefinition tříd a SMS_SCI_SiteDefinition . Tyto třídy spravují samotný řídicí soubor webu. Změnou některých konfigurovatelných položek můžete způsobit významné poškození webu.

Konfigurace nastavení agenta klienta

  1. Nastavte připojení k poskytovateli serveru SMS. Další informace najdete v tématu Základy poskytovatele serveru SMS.

  2. Vytvořte připojení k části klientské součásti distribuce softwaru řídicího souboru lokality pomocí třídy SMS_SCI_ClientComp .

  3. Procházte polem dostupných vlastností a proveďte změny podle potřeby.

  4. Potvrďte změny vlastností v souboru ovládacího prvku lokality.

Příklad

Následující příklad se dotazuje na konkrétní položky v části součásti klienta distribuce softwaru řídicího souboru lokality a upraví tato konkrétní nastavení klientského agenta.

Informace o volání ukázkového kódu najdete v tématu Volání Configuration Manager fragmentů kódu.


Sub ConfigureClientAgentSettings(swbemServices, swbemContext, siteToChange, enableDisableSWDClientAgent, enableDisableRequestUserPolicy, setPolicyRefreshInterval, enableDisableVisibleSignalOnAvailable, enableDisableAudibleSignalonAvailable,enableDisableCountdownSignal,setCountdownMinutes, enableDisableShowIcon)  

    ' Load site control file and get SWD client component section.  
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteToChange & """", "Refresh", , , swbemContext  
    Set objSWbemInst = swbemServices.Get("SMS_SCI_ClientComp.Filetype=1,Itemtype='Client Component',Sitecode='" & siteToChange & "',ItemName='Software Distribution'", , swbemContext)  

    ' Display SWD client agent settings before change.  
    Wscript.Echo " "  
    Wscript.Echo "Before Change"  
    Wscript.Echo "-------------"  

    Wscript.Echo " "  
    Wscript.Echo objSWbemInst.ClientComponentName  
    Wscript.Echo "Current value: " & objSWbemInst.Flags & " (0 = Disabled, 1 = Enabled)"  
    Wscript.Echo " "  
    objSWbemInst.Flags = enableDisableSWDClientAgent  

    ' Enumerate though the property array, but display only the properties that we're specifically interested in.  
    ' Note: A list of all properties could be generated by just using the following code:  
    '     PropertyArray = objSwbemInst.props  
    '     For i = 0 to ubound(PropertyArray)  
    '        Wscript.Echo PropertyArray(i).PropertyName  
    '        Wscript.Echo "Current value: " & PropertyArray(i).Value  
    '     Next  

    PropertyArray = objSwbemInst.props  
    For i = 0 to ubound(PropertyArray)  

        ' Client settings: Allow user targeted advertisement requests.  
        If PropertyArray(i).PropertyName = "Request User Policy" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = enableDisableRequestUserPolicy   
        End If  

        ' Client settings: Policy polling interval (minutes).  
        If PropertyArray(i).PropertyName = "Policy Refresh Interval" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = setPolicyRefreshInterval   
        End If  

        ' When new advertised programs are available: Display a notification message.  
        If PropertyArray(i).PropertyName = "Visible Signal on Available" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = enableDisableVisibleSignalOnAvailable   
        End If  

        ' When new advertised programs are available: Play a sound.  
        If PropertyArray(i).PropertyName = "Audible Signal on Available" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = enableDisableAudibleSignalonAvailable   
        End If  

        ' When a scheduled program is about to run: Provide a countdown.  
        If PropertyArray(i).PropertyName = "Countdown Signal" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = enableDisableCountdownSignal   
        End If  

        ' Countdown length (minutes).  
        If PropertyArray(i).PropertyName = "Countdown Minutes" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = setCountdownMinutes   
        End If  

        ' Show advertised program notification icons in the notification area.  
        If PropertyArray(i).PropertyName = "Show Icon" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
            PropertyArray(i).Value = enableDisableShowIcon   
        End If  
    Next  

    ' Save new client agent settings.  
    objSWbemInst.Put_ , swbemContext  
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteToChange & """", "Commit", , , swbemContext  

    ' Refresh in-memory copy of the site control file and get the SWD client component section.  
    swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteToChange & """", "Refresh", , , swbemContext  
    Set objSWbemInst = swbemServices.Get("SMS_SCI_ClientComp.Filetype=1,Itemtype='Client Component',Sitecode='" & siteToChange & "',ItemName='Software Distribution'", , swbemContext)  

    ' Display SWD client agent settings after change.  

    Wscript.Echo " "  
    Wscript.Echo "After Change"  
    Wscript.Echo "------------"  

    Wscript.Echo " "  
    Wscript.Echo objSWbemInst.ClientComponentName  
    Wscript.Echo "Current value: " & objSWbemInst.Flags & " (0 = Disabled, 1 = Enabled)"  
    Wscript.Echo " "  

    PropertyArray = objSwbemInst.props  
    For i = 0 to ubound(PropertyArray)  

        ' Client settings: Allow user targeted advertisement requests.  
        If PropertyArray(i).PropertyName = "Request User Policy" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  

        ' Client settings: Policy polling interval (minutes).  
        If PropertyArray(i).PropertyName = "Policy Refresh Interval" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  

        ' When new advertised programs are available: Display a notification message.  
        If PropertyArray(i).PropertyName = "Visible Signal on Available" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  

        ' When new advertised programs are available: Play a sound.  
        If PropertyArray(i).PropertyName = "Audible Signal on Available" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  

        ' When a scheduled program is about to run: Provide a countdown.  
        If PropertyArray(i).PropertyName = "Countdown Signal" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  

        ' Countdown length (minutes).  
        If PropertyArray(i).PropertyName = "Countdown Minutes" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  

        ' Show advertised program notification icons in the notification area.  
        If PropertyArray(i).PropertyName = "Show Icon" Then  
            Wscript.Echo PropertyArray(i).PropertyName  
            Wscript.Echo "Current value: " & PropertyArray(i).Value  
            Wscript.Echo " "  
        End If  
    Next  

End Sub  
public void ConfigureSWDClientAgentSettings(WqlConnectionManager connection, string siteCode, string enableDisableSWDClientAgent, string enableDisableRequestUserPolicy, string setPolicyRefreshInterval, string enableDisableVisibleSignalOnAvailable, string enableDisableAudibleSignalonAvailable, string enableDisableCountdownSignal, string setCountdownMinutes, string enableDisableShowIcon)  
{  
try  
{  
    IResultObject siteDefinition = connection.GetInstance(@"SMS_SCI_ClientComp.FileType=1,ItemType='Client Component',SiteCode='" + siteCode + "',ItemName='Software Distribution'");  

    Console.WriteLine();  
    Console.WriteLine("Before Change");  
    Console.WriteLine("-------------");  

    // Enable software distribution to clients.  
    // Set SWD client agent by setting flags value to  0 or 1 using the EnableDisableSWDClientAgent variable.  
    Console.WriteLine("Software Distribution Client Agent");  
    Console.WriteLine("Current value: " + siteDefinition["Flags"].StringValue + " (0 = Disabled, 1 = Enabled)");  
    siteDefinition["Flags"].StringValue = enableDisableSWDClientAgent;  

    foreach (KeyValuePair<string, IResultObject> kvp in siteDefinition.EmbeddedProperties)  
    {  
        Dictionary<string, IResultObject> embeddedProperties = siteDefinition.EmbeddedProperties; // temp copy  

        // Client settings: Allow user targeted advertisement requests.  
        if (kvp.Value.PropertyList["PropertyName"] == "Request User Policy")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Request User Policy"]["Value"].StringValue);  
            embeddedProperties["Request User Policy"]["Value"].StringValue = enableDisableRequestUserPolicy;  
        }  

        // Client settings: Policy polling interval (minutes).  
        if (kvp.Value.PropertyList["PropertyName"] == "Policy Refresh Interval")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Policy Refresh Interval"]["Value"].StringValue);  
            embeddedProperties["Policy Refresh Interval"]["Value"].StringValue = setPolicyRefreshInterval;  
        }  

        // When new advertised programs are available: Display a notification message.  
        if (kvp.Value.PropertyList["PropertyName"] == "Visible Signal on Available")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Visible Signal on Available"]["Value"].StringValue);  
            embeddedProperties["Visible Signal on Available"]["Value"].StringValue = enableDisableVisibleSignalOnAvailable;  
        }  

        // When new advertised programs are available: Play a sound.  
        if (kvp.Value.PropertyList["PropertyName"] == "Audible Signal on Available")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Audible Signal on Available"]["Value"].StringValue);  
            embeddedProperties["Audible Signal on Available"]["Value"].StringValue = enableDisableAudibleSignalonAvailable;                      
        }  

        // When a scheduled program is about to run: Provide a countdown.  
        if (kvp.Value.PropertyList["PropertyName"] == "Countdown Signal")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Countdown Signal"]["Value"].StringValue);  
            embeddedProperties["Countdown Signal"]["Value"].StringValue = enableDisableCountdownSignal;  
        }  

        // Countdown length (minutes).  
        if (kvp.Value.PropertyList["PropertyName"] == "Countdown Minutes")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Countdown Minutes"]["Value"].StringValue);  
            embeddedProperties["Countdown Minutes"]["Value"].StringValue = setCountdownMinutes;  
        }  

        // Show advertised program notification icons in the notification area.  
        if (kvp.Value.PropertyList["PropertyName"] == "Show Icon")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Show Icon"]["Value"].StringValue);  
            embeddedProperties["Show Icon"]["Value"].StringValue = enableDisableShowIcon;  
        }  

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

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

    // Verify change by reconnecting and getting the value again.  
    IResultObject siteDefinition2 = connection.GetInstance(@"SMS_SCI_ClientComp.FileType=1,ItemType='Client Component',SiteCode='" + siteCode + "',ItemName='Software Distribution'");  

    Console.WriteLine();  
    Console.WriteLine("After Change");  
    Console.WriteLine("-------------");  

    // Enable software distribution to clients.  
    Console.WriteLine("Software Distribution Client Agent");  
    Console.WriteLine("Current value: " + siteDefinition2["Flags"].StringValue + " (0 = Disabled, 1 = Enabled)");  

    foreach (KeyValuePair<string, IResultObject> kvp in siteDefinition2.EmbeddedProperties)  
    {  
        Dictionary<string, IResultObject> embeddedProperties = siteDefinition2.EmbeddedProperties; // temp copy  

        // Client settings: Allow user targeted advertisement requests.  
        if (kvp.Value.PropertyList["PropertyName"] == "Request User Policy")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Request User Policy"]["Value"].StringValue);  
        }  

        // Client settings: Policy polling interval (minutes).  
        if (kvp.Value.PropertyList["PropertyName"] == "Policy Refresh Interval")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Policy Refresh Interval"]["Value"].StringValue);  
        }  

        // When new advertised programs are available: Display a notification message.  
        if (kvp.Value.PropertyList["PropertyName"] == "Visible Signal on Available")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Visible Signal on Available"]["Value"].StringValue);  
        }  

        // When new advertised programs are available: Play a sound.  
        if (kvp.Value.PropertyList["PropertyName"] == "Audible Signal on Available")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Audible Signal on Available"]["Value"].StringValue);  
        }  

        // When a scheduled program is about to run: Provide a countdown.  
        if (kvp.Value.PropertyList["PropertyName"] == "Countdown Signal")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Countdown Signal"]["Value"].StringValue);  
        }  

        // Countdown length (minutes).  
        if (kvp.Value.PropertyList["PropertyName"] == "Countdown Minutes")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Countdown Minutes"]["Value"].StringValue);  
        }  

        // Show advertised program notification icons in the notification area.  
        if (kvp.Value.PropertyList["PropertyName"] == "Show Icon")  
        {  
            Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);  
            Console.WriteLine("Current value: " + embeddedProperties["Show Icon"]["Value"].StringValue);  
        }  
    }  

    Console.WriteLine(" ");  
}  

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

}  

Ukázková metoda má následující parametry:

Parametr Typ Popis
connection

swbemServices
-Spravované: WqlConnectionManager
- VBScript: SWbemServices
Platné připojení k poskytovateli serveru SMS.
swbemContext -Vbscript: SWbemContext Platný kontextový objekt. Další informace najdete v tématu Přidání kvalifikátoru kontextu Configuration Manager pomocí rozhraní WMI.
siteCode

siteToChange
-Spravované: String
-Vbscript: String
Kód lokality.
enableDisableSWDClientAgent -Spravované: String
-Vbscript: String
Příznak pro povolení nebo zakázání klientského agenta
setPolicyRefreshInterval -Spravované: String
-Vbscript: String
Interval dotazování zásad v minutách
enableDisableRequestUserPolicy -Spravované: String
-Vbscript: String
Příznakem povolíte nebo zakážete cílené žádosti o inzerci.
enableDisableVisibleSignalOnAvailable -Spravované: String
-Vbscript: String
Příznakem povolíte nebo zakážete zobrazování oznámení, když jsou k dispozici nové inzerované programy.
enableDisableAudibleSignalonAvailable -Spravované: String
-Vbscript: String
Příznakem povolíte nebo zakážete zvukové oznámení, když jsou k dispozici nové inzerované programy.
enableDisableCountdownSignal -Spravované: String
-Vbscript: String
Příznakem povolíte nebo zakážete odpočítávání, když se naplánovaný program chystá spustit.
setCountdownMinutes -Spravované: String
-Vbscript: String
Odpočítávání délky v minutách.
enableDisableShowIcon -Spravované: String
-Vbscript: String
Příznakem povolíte nebo zakážete zobrazení ikon oznámení inzerovaného programu v oznamovací oblasti.

Kompilace kódu

Příklad jazyka C# vyžaduje:

Obory názvů

Systému

System.collections.generic

System.componentmodel

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Sestavení

adminui.wqlqueryengine

microsoft.configurationmanagement.managementprovider

Robustní programování

Další informace o zpracování chyb najdete v tématu Informace o chybách Configuration Manager.

Zabezpečení rozhraní .NET Framework

Další informace o zabezpečení Configuration Manager aplikací najdete v tématu Configuration Manager správa na základě rolí.

Viz taky

Přehled distribuce softwaruInformace o nastavení a konfiguraci distribuce softwaruInformace o řídicím souboru Configuration Manager webu
Čtení a zápis do řídicího souboru webu Configuration Manager pomocí spravovaného kódu
Čtení a zápis do řídicího souboru webu Configuration Manager pomocí rozhraní WMI
Serverová třída služby WMI SMS_SCI_Component