サイト コントロール ファイルを変更して、Configuration Managerでモバイル デバイス クライアント エージェントの設定を構成します。
重要
この記事は、モバイル デバイスレガシ クライアントにのみ適用されます。
モバイル デバイス クライアント エージェントの設定を構成するには
SMS プロバイダーへの接続を設定します。
クラスを使用して、サイト コントロール ファイルの [デバイス クライアント] セクションに接続します
SMS_SCI_ClientComp
。使用可能なプロパティの配列をループして、必要に応じて変更を加えます。
プロパティの変更をサイト コントロール ファイルにコミットします。
例
次のメソッド例では、 クラスを使用してサイト コントロール ファイルに接続し、プロパティを SMS_SCI_ClientComp
変更することで、さまざまな Mobile Device Client Agent 設定を構成します。
サンプル コードの呼び出しについては、「Configuration Manager コード スニペットの呼び出し」を参照してください。
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;
}
}
このメソッドの例には、次のパラメーターがあります。
パラメーター | 型 | 説明 |
---|---|---|
connection swbemServices |
-管理: WqlConnectionManager - VBScript: SWbemServices |
SMS プロバイダーへの有効な接続。 |
swbemContext |
-Vbscript: SWbemContext |
有効なコンテキスト オブジェクト。 詳細については、「WMI を使用してConfiguration Managerコンテキスト修飾子を追加する方法」を参照してください。 |
siteCode |
-管理: String -Vbscript: String |
サイト コード。 |
newPollInterval |
-管理: String -Vbscript: String |
クライアントがサーバーへの接続を試みる間隔。 文字列の形式は次のとおりです。 年 -months-days 時間:分:秒 "0000-00-00 00:00:00" |
newPollIntervalMinutes |
-管理: String -Vbscript: String |
文字列の newPollInterval 分数を表す値。 |
newPollIntervalHours |
-管理: String -Vbscript: String |
文字列の newPollInterval 時間を表す値。 |
newFailureRetryCount |
-管理: String -Vbscript: String |
文字列の newPollInterval 時間を表す値。 |
newFailureRetryIntervalMinutes |
-管理: String -Vbscript: String |
文字列の newFailureRetryInterval 分数を表す値。 |
newFailureRetryIntervalHours |
-管理: String -Vbscript: String |
文字列の newFailureInterval 時間を表す値。 |
newEnableDisableSoftwareDistribution |
-管理: Boolean -Vbscript: Boolean |
ソフトウェア配布を有効または無効にする値。 Enabled = true Disabled = false |
コードのコンパイル
この C# の例では、次のものが必要です。
名前空間
System
System.Collections.Generic
System.text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
adminui.wqlqueryengine
microsoft.configurationmanagement.managementprovider
堅牢なプログラミング
エラー処理の詳細については、「Configuration Manager エラーについて」を参照してください。
.NET Framework のセキュリティ
Configuration Manager アプリケーションのセキュリティ保護の詳細については、「ロールベースの管理Configuration Manager」を参照してください。
関連項目
ソフトウェア Updatesのセットアップと構成について
サイトコントロールファイルのConfiguration Managerについて
マネージド コードを使用してConfiguration Manager サイト コントロール ファイルの読み取りと書き込みを行う方法
WMI を使用してConfiguration Manager サイト コントロール ファイルの読み取りと書き込みを行う方法
SMS_SCI_Component サーバー WMI クラス