Configuration Managerでは、クライアント構成クラスのインスタンスを作成し、そのクラスのインスタンスを作成し、Client Configuration クラスのインスタンスSMS_ClientSettingsAssignment
とターゲット コレクションを関連付けることによってカスタム クライアント設定をデプロイすることで、カスタム クライアント設定を適用します。
カスタム クライアント設定を適用するには
SMS プロバイダーへの接続を設定します。
クライアント構成クラスのインスタンスを作成します (次に示すように
SMS_StateSystemConfig
)。特定のカスタム クライアント エージェント設定を設定します。
クラスのインスタンスを
SMS_ClientSettingsAssignment
作成します。クライアント設定の割り当て値を設定します。
ClientSettingsID
カスタム クライアント設定インスタンスを識別し、CollectionID
カスタム クライアント設定のデプロイのターゲット コレクションを識別します。
例
次の例では、Client Configuration クラスのインスタンスを作成し、そのクラスのインスタンスを作成し、Client Configuration クラスのインスタンス SMS_ClientSettingsAssignment
とターゲット コレクションを関連付けることによって、カスタム クライアント設定をデプロイすることで、カスタム クライアント設定を適用します。
サンプル コードの呼び出しについては、「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);
}
}
このメソッドの例には、次のパラメーターがあります。
パラメーター | 型 | 説明 |
---|---|---|
connection |
-管理: WqlConnectionManager |
SMS プロバイダーへの有効な接続。 |
targetCollectionID |
-管理: String |
カスタム クライアント設定の展開のターゲット コレクション。 |
コードのコンパイル
この 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」を参照してください。
関連項目
Configuration Manager SDK
SMS_ClientSettingsAssignment サーバー WMI クラス