How to Add 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 add an operating system image package by creating an instance of SMS_ImagePackage class. The path to the Windows Image (WIM) file is specified in the PkgSourcePath property as a Universal Naming Convention (UNC) path.

To create 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. Create an instance of SMS_ImagePackage.

  3. Specify the path to the WIM file in PkgSourcePath.

  4. Commit the SMS_ImagePackage class instance.

Example

The following example method creates an operating system package.

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

Sub AddOSImagePackage(connection, newImagePackageName, newImagePackageDescription, newImagePackageSourcePath)

    Dim newImagePackage
    
    Set newImagePackage = connection.Get("SMS_ImagePackage").SpawnInstance_()
    ' Populate the new package properties.
    newImagePackage.Name = newImagePackageName
    newImagePackage.Description = newImagePackageDescription
    newImagePackage.PkgSourceFlag = 2
    newImagePackage.PkgSourcePath = newImagePackageSourcePath

    ' Save the package.
     newImagePackage.Put_
 
End Sub
public void AddOSImagePackage(
    WqlConnectionManager connection, 
    string newImagePackageName, 
    string newImagePackageDescription, 
    string newImagePackageSourcePath)
{
    try
    {
        // Create new package object.
        IResultObject newImagePackage = connection.CreateInstance("SMS_ImagePackage");

        // Populate new package properties.
        newImagePackage["Name"].StringValue = newImagePackageName;
        newImagePackage["Description"].StringValue = newImagePackageDescription;
        newImagePackage["PkgSourceFlag"].IntegerValue = (int)PackageSourceFlag.StorageDirect;
        newImagePackage["PkgSourcePath"].StringValue = newImagePackageSourcePath;

        // Save new package and new package properties.
        newImagePackage.Put();
    }
    catch (SmsException e)
    {
        Console.WriteLine();
        Console.WriteLine("Failed to create package. Error: " + 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.

newImagePackageName

  • Managed: String

  • VBScript: String

The new image package name.

newImagePackageDescription

  • Managed: String

  • VBScript: String

The new image package description

newImagePackageSourcePath

  • Managed: String

  • VBScript: String

The UNC path to the WIM file.

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.

See Also

Concepts

Operating System Deployment Image Management
How to Assign a Package to a Distribution Point