You add an operating system install package to Microsoft System Center Configuration Manager 2007 by creating and populating an instance of SMS_OperatingSystemInstallPackage Server WMI Class.

To add an operating system install 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_OperatingSystemInstallPackage.

  3. Set at least the Name, PkgSourceFlag and PkgSourcePath properties.

  4. Commit the changes.

Example

The following example method adds an operating system install package.

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

Visual Basic Script  Copy Code
Sub AddOSInstallPackage(connection, name, description, path)

	Dim osInstallPackage

	Set osInstallPackage = connection.Get("SMS_OperatingSystemInstallPackage").SpawnInstance_()
	' Populate the new package properties.
	osInstallPackage.Name = name
	osInstallPackage.Description = description

	osInstallPackage.PkgSourceFlag=2
	osInstallPackage.PkgSourcePath = path
  
	' Write the package.
	osInstallPackage.Put_
 
End Sub
C#  Copy Code
public void AddOSInstallPackage(
	WqlConnectionManager connection, 
	string name, 
	string description, 
	string path)
{
	try
	{
		// Create new operating system image package object.
		IResultObject osInstallPackage = connection.CreateInstance("SMS_OperatingSystemInstallPackage");

		// Populate operating system package properties.
		osInstallPackage["Name"].StringValue = name;
		osInstallPackage["Description"].StringValue = description;
		osInstallPackage["PkgSourceFlag"].IntegerValue = (int)PackageSourceFlag.StorageDirect;
		osInstallPackage["PkgSourcePath"].StringValue = path;

		// Save operating system package.
		osInstallPackage.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.

name

  • Managed: String

  • VBScript: String

Name for the new operating system image package.

description

  • Managed: String

  • VBScript: String

Description for the operating system image package.

path

  • Managed: Integer

  • VBScript: Integer

Universal Naming Convention (UNC) path to the image Windows Image (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


Send comments about this topic to Microsoft.