Anteckning
Åtkomst till den här sidan kräver auktorisering. Du kan prova att logga in eller ändra kataloger.
Åtkomst till den här sidan kräver auktorisering. Du kan prova att ändra kataloger.
Du konfigurerar inställningarna för klientagenten för mobila enheter i Configuration Manager genom att ändra platskontrollfilen.
Viktigt
Den här artikeln gäller endast den äldre klienten för mobila enheter.
Så här konfigurerar du inställningarna för klientagenten för mobila enheter
Konfigurera en anslutning till SMS-providern.
Upprätta en anslutning till avsnittet Enhetsklient i platskontrollfilen med hjälp
SMS_SCI_ClientComp
av klassen .Gå igenom matrisen med tillgängliga egenskaper och gör ändringar efter behov.
Checka in egenskapsändringarna i platskontrollfilen.
Exempel
Följande exempelmetod konfigurerar olika klientagentinställningar för mobila enheter med hjälp SMS_SCI_ClientComp
av klassen för att ansluta till platskontrollfilen och ändra egenskaper.
Information om hur du anropar exempelkoden finns i Anropa Configuration Manager kodfragment.
Sub ConfigureMobileDeviceClientAgentSettings(swbemServices, _
swbemContext, _
siteCode, _
newPollIntervalMinutes, _
newPollIntervalHours, _
newFailureRetryCount, _
newFailureRetryIntervalMinutes, _
newFailureRetryIntervalHours, _
newEnableDisableSoftwareDistribution)
' Variables to build poll interval string.
' Note: The sample code only passes in minutes and hours, so setting empty values to use.
emptySeconds = "00"
emptyDays = "00"
emptyMonths = "00"
emptyYears = "0000"
' Build newPollInterval string (the format must be "0000-00-00 00:00:00").
newPollInterval = emptyYears & "-" & emptyMonths & "-" & emptyDays & " " & newPollIntervalHours & ":" & newPollIntervalMinutes & ":" & emptySeconds
newFailureRetryInterval = emptyYears & "-" & emptyMonths & "-" & emptyDays & " " & newFailureRetryIntervalHours & ":" & newFailureRetryIntervalMinutes & ":" & emptySeconds
' Load site control file and get the client component section.
swbemServices.ExecMethod "SMS_SiteControlFile.Filetype=1,Sitecode=""" & siteCode & """", "Refresh", , , swbemContext
Query = "SELECT * FROM SMS_SCI_ClientComp " & _
"WHERE ClientComponentName = 'Device Client' " & _
"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
' Loop through the array of embedded property instances.
For Each vProperty In SCIComponent.Props
' Setting: Poll Interval
If vProperty.PropertyName = "Poll Interval" Then
wscript.echo " "
wscript.echo vProperty.PropertyName
wscript.echo "Current value " & vProperty.Value2
'Modify the value.
vProperty.Value2 = newPollInterval
wscript.echo "New value " & newPollInterval
End If
' Setting: Failure Retry Count
If vProperty.PropertyName = "Failure Retry Count" Then
wscript.echo " "
wscript.echo vProperty.PropertyName
wscript.echo "Current value " & vProperty.Value
' Modify the value.
vProperty.Value = newFailureRetryCount
wscript.echo "New value " & newFailureRetryCount
End If
' Setting: Failure Retry Interval
If vProperty.PropertyName = "Failure Retry Interval" Then
wscript.echo " "
wscript.echo vProperty.PropertyName
wscript.echo "Current value " & vProperty.Value2
' Modify the value.
vProperty.Value2 = newFailureRetryInterval
wscript.echo "New value " & newFailureRetryInterval
End If
' Setting: Enable Software Dist
If vProperty.PropertyName = "Enable Software Dist" Then
wscript.echo " "
wscript.echo vProperty.PropertyName
wscript.echo "Current value " & vProperty.Value2
' Modify the value.
vProperty.Value2 = newEnableDisableSoftwareDistribution
wscript.echo "New value " & newEnableDisableSoftwareDistribution
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 ConfigureMobileDeviceClientAgentSettings(WqlConnectionManager connection,
string siteCode,
string newPollIntervalMinutes,
string newPollIntervalHours,
string newFailureRetryCount,
string newFailureRetryIntervalMinutes,
string newFailureRetryIntervalHours,
bool newEnableDisableSoftwareDistribution)
{
// Define variables to build poll interval string.
// Note: The example code only passes in minutes and hours, so this sets empty values to use.
string emptyDays = "00";
string emptyMonths = "00";
string emptyYears = "0000";
string emptySeconds = "00";
// Build newPollInterval and newFailureRetryInterval strings (the format must be "0000-00-00 00:00:00").
string newPollInterval = emptyYears + "-" + emptyMonths + "-" + emptyDays + " " + newPollIntervalHours + ":" + newPollIntervalMinutes + ":" + emptySeconds;
string newFailureRetryInterval = emptyYears + "-" + emptyMonths + "-" + emptyDays + " " + newFailureRetryIntervalHours + ":" + newFailureRetryIntervalMinutes + ":" + emptySeconds;
try
{
IResultObject siteDefinition = connection.GetInstance(@"SMS_SCI_ClientComp.FileType=1,ItemType='Client Component',SiteCode='" + siteCode + "',ItemName='Device Client'");
// Loop through the array of embedded properties.
foreach (KeyValuePair<string, IResultObject> kvp in siteDefinition.EmbeddedProperties)
{
// Create temporary working copy of embedded properties.
Dictionary<string, IResultObject> embeddedProperties = siteDefinition.EmbeddedProperties;
// Setting: Poll Interval.
if (kvp.Value.PropertyList["PropertyName"] == "Poll Interval")
{
Console.WriteLine();
Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);
Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value2"].StringValue);
// Change value using the newPollInterval value passed in.
embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value2"].StringValue = newPollInterval;
Console.WriteLine("New value : " + newPollInterval);
}
// Setting: Failure Retry Count.
if (kvp.Value.PropertyList["PropertyName"] == "Failure Retry Count")
{
Console.WriteLine();
Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);
Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue);
// Change value using the newFailureRetryCount value passed in.
embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value"].StringValue = newFailureRetryCount;
Console.WriteLine("New value : " + newFailureRetryCount);
}
// Setting: Failure Retry Interval.
if (kvp.Value.PropertyList["PropertyName"] == "Failure Retry Interval")
{
Console.WriteLine();
Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);
Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value2"].StringValue);
// Change value using the newFailureRetryInterval value passed in.
embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value2"].StringValue = newFailureRetryInterval;
Console.WriteLine("New value : " + newFailureRetryInterval);
}
// Setting: Enable Software Dist.
if (kvp.Value.PropertyList["PropertyName"] == "Enable Software Dist")
{
Console.WriteLine();
Console.WriteLine(kvp.Value.PropertyList["PropertyName"]);
Console.WriteLine("Current value: " + embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value2"].StringValue);
// Change value using the newEnableDisableSoftwareDistribution value passed in.
embeddedProperties[kvp.Value.PropertyList["PropertyName"]]["Value2"].BooleanValue = newEnableDisableSoftwareDistribution;
Console.WriteLine("New value : " + newEnableDisableSoftwareDistribution);
}
// 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;
}
}
Exempelmetoden har följande parametrar:
Parameter | Typ | Beskrivning |
---|---|---|
connection swbemServices |
-Hanterade: WqlConnectionManager – VBScript: SWbemServices |
En giltig anslutning till SMS-providern. |
swbemContext |
-Vbscript: SWbemContext |
Ett giltigt kontextobjekt. Mer information finns i How to Add a Configuration Manager Context Qualifier by Using WMI (Lägga till en Configuration Manager kontextkvalificerare med hjälp av WMI). |
siteCode |
-Hanterade: String -Vbscript: String |
Platskoden. |
newPollInterval |
-Hanterade: String -Vbscript: String |
Intervallet som klienten försöker kontakta servern. Strängens format måste vara: Timmar i flera månader:minuter:sekunder "0000-00-00 00:00:00" |
newPollIntervalMinutes |
-Hanterade: String -Vbscript: String |
Ett värde som representerar strängens newPollInterval minuter. |
newPollIntervalHours |
-Hanterade: String -Vbscript: String |
Ett värde som representerar timmarna för strängen newPollInterval . |
newFailureRetryCount |
-Hanterade: String -Vbscript: String |
Ett värde som representerar timmarna för strängen newPollInterval . |
newFailureRetryIntervalMinutes |
-Hanterade: String -Vbscript: String |
Ett värde som representerar strängens newFailureRetryInterval minuter. |
newFailureRetryIntervalHours |
-Hanterade: String -Vbscript: String |
Ett värde som representerar timmarna för strängen newFailureInterval . |
newEnableDisableSoftwareDistribution |
-Hanterade: Boolean -Vbscript: Boolean |
Ett värde som aktiverar eller inaktiverar programvarudistribution. Aktiverad = true Inaktiverad = false |
Kompilera koden
Det här C#-exemplet kräver:
Namnområden
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Församlingen
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
Robust programmering
Mer information om felhantering finns i Om Configuration Manager fel.
.NET Framework Säkerhet
Mer information om hur du skyddar Configuration Manager program finns i Configuration Manager rollbaserad administration.
Se även
Om installation och konfiguration av programvara Uppdateringar
Om Configuration Manager-platskontrollfilen
Läsa och skriva till Configuration Manager platskontrollfil med hjälp av hanterad kod
Läsa och skriva till Configuration Manager platskontrollfil med hjälp av WMI
SMS_SCI_Component, serverns WMI-klass