Configuration Managerでは、SMS_ImagePackage クラス インスタンスGetImageProperties メソッドを呼び出して、オペレーティング システム パッケージに含まれている Windows Image (WIM) ファイルのイメージ プロパティを表示します。
イメージ プロパティは XML 形式で使用できます。
イメージのプロパティを表示するには
SMS プロバイダーへの接続を設定します。 詳細については、「 SMS プロバイダーの基礎」を参照してください。
更新する
SMS_ImagePackage
クラス インスタンスを取得します。GetImageProperties クラス インスタンス メソッドを呼び出します。
ImageProperty パラメーターを使用してプロパティ XML にアクセスします。
例
次の例では、パッケージを定義するオペレーティング システム イメージ パッケージ プロパティ XML を表示します。
サンプル コードの呼び出しについては、「Configuration Manager コード スニペットの呼び出し」を参照してください。
Sub ViewOSImage(connection,imagePackageID)
Dim imagePackage
Dim inParam
Dim outParams
' Get the image.
Set imagePackage = connection.Get("SMS_ImagePackage.PackageID='" & imagePackageID & "'")
' Obtain an InParameters object specific
' to the method.
Set inParam = imagePackage.Methods_("GetImageProperties"). _
inParameters.SpawnInstance_()
' Add the input parameters.
inParam.Properties_.Item("SourceImagePath") = imagePackage.PkgSourcePath
' Execute the method.
Set outParams = connection.ExecMethod("SMS_ImagePackage", "GetImageProperties", inParam)
' Display the image properties XML.
Wscript.echo "ImageProperty: " & outParams.ImageProperty
End Sub
public void ViewOSImage(
WqlConnectionManager connection,
string imagePackageId)
{
try
{
IResultObject imagePackage = connection.GetInstance(@"SMS_ImagePackage.PackageID='" + imagePackageId + "'");
Dictionary<string, Object> inParams = new Dictionary<string, object>();
inParams.Add("SourceImagePath", imagePackage["PkgSourcePath"].StringValue);
IResultObject result = connection.ExecuteMethod("SMS_ImagePackage", "GetImageProperties", inParams);
Console.WriteLine(result["ImageProperty"].StringValue);
}
catch (SmsException e)
{
Console.WriteLine(e.Message);
throw;
}
}
このメソッドの例には、次のパラメーターがあります。
パラメーター | 型 | 説明 |
---|---|---|
connection |
-管理: WqlConnectionManager - VBScript: SWbemServices |
SMS プロバイダーへの有効な接続。 |
imagePackageID |
-管理: String -Vbscript: String |
パッケージ イメージ識別子。 から入手できます SMS_ImagePackage. PackageID 。 |
コードのコンパイル
C# の例には、次のコンパイル要件があります。
名前空間
System
System.Collections.Generic
System.text
Microsoft。ConfigurationManagement.ManagementProvider
Microsoft。ConfigurationManagement.ManagementProvider.WqlQueryEngine
Assembly
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
堅牢なプログラミング
エラー処理の詳細については、「Configuration Manager エラーについて」を参照してください。
.NET Framework のセキュリティ
Configuration Manager アプリケーションのセキュリティ保護の詳細については、「ロールベースの管理Configuration Manager」を参照してください。