Partager via


How to Update an Operating System Image Package in Configuration Manager

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

In Microsoft System Center Configuration Manager 2007, you update the Windows Image (WIM) file that is associated with the operating system package by calling the image package's SMS_ImagePackage class instance ReloadImageProperties method. The image is updated based on the location defined in the pkgSourcePath property.

To update an operating system image package

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Get the SMS_ImagePackage class instance you want to update.

  3. Call the ReloadImageProperties class instance method.

  4. Commit the SMS_ImagePackage class instance.

Example

The following example updates an operating system image package.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Sub UpdateOSImage(connection,imagePackageID, sourcePath)
    
    Dim imagePackage
    
    ' Get the image.
    set imagePackage = connection.Get("SMS_ImagePackage.PackageID='" & imagePackageID & "'")
    
    ' Update the source.
    imagePackage.PkgSourcePath=sourcePath
    imagePackage.Put_
    imagePackage.RefreshPkgSource 
    
End Sub
public void UpdateOSImage(
    WqlConnectionManager connection, 
    string imagePackageId, 
    string sourcePath)
{
    try
    {
        // Get the image package.
        IResultObject imagePackage = connection.GetInstance(@"SMS_ImagePackage.PackageID='" + imagePackageId + "'");

        // Update the location.
        imagePackage["PkgSourcePath"].StringValue = sourcePath;
        imagePackage.Put();
        imagePackage.ExecuteMethod("RefreshPkgSource", null);
    }
    catch (SmsException e)
    {
        Console.WriteLine(e.Message);
        throw;
    }
}

The example method has the following parameters:

Parameter

Type

Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

imagePackageID

  • Managed: String

  • VBScript: String

The package image identifier. It is available from SMS_ImagePackage. PackageID.

sourcePath

  • Managed: String

  • VBScript: String

The path to the image package source in Universal Naming Convention (UNC) format.

Compiling the Code

The C# example has the following compilation requirements:

Namespaces

System

System.Collections.Generic

System.Text

Microsoft.ConfigurationManagement.ManagementProvider

Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine

Assembly

microsoft.configurationmanagement.managementprovider

adminui.wqlqueryengine

Robust Programming

For more information about error handling, see About Configuration Manager Errors.

Security

For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.