如何查看操作系统映像的属性

在 Configuration Manager 中,可以通过调用 SMS_ImagePackage 类实例 GetImageProperties 方法查看包含在操作系统包中的 Windows 映像 ( WIM) 文件的映像属性。

图像属性以 XML 格式提供。

查看图像属性

  1. 设置与 SMS 提供程序的连接。 有关详细信息,请参阅 SMS 提供程序基础知识

  2. 获取 SMS_ImagePackage 要更新的类实例。

  3. 调用 GetImageProperties 类实例方法。

  4. 使用 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基于角色的管理

另请参阅

关于映像管理