You add a boot image from a Windows Image (WIM) file to System Center 2012 Configuration Manager by creating an instance of SMS_BootImagePackage Server WMI Class. The property ImagePath must be set to the Universal Naming Convention (UNC) path to the WIM file. The property ImageIndex is the index to the required image within the WIM file.
If the boot image requires Windows drivers, you specify them in the ReferencedDrivers property, which is an array of SMS_Driver_Details Server WMI Class.
Note |
---|
When the boot image is updated, for example, when a System Center 2012 Configuration Manager binary or boot image property is changed, the boot image must be updated by calling the SMS_BootImagePackage class RefreshPkgSource method. |
To add a boot image from a WIM file
-
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
-
Create an instance of SMS_BootImagePackage.
-
Set at least the Name, ImagePath and ImageIndex properties.
-
Commit the changes.
Example
The following example method adds a boot image from a WIM file.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Visual Basic Script | Copy Code |
---|---|
Sub AddBootImagePackage(connection, name, description, pathToWim) Dim bootImagePackage Set bootImagePackage = connection.Get("SMS_BootImagePackage").SpawnInstance_() ' Populate the new package properties. bootImagePackage.Name = name bootImagePackage.Description = description bootImagePackage.ImagePath = pathToWim 'UNC path to WIM file. bootImagePackage.ImageIndex = 1 ' Index into WIM file for image bootImagePackage.Put_ End Sub |
C# | Copy Code |
---|---|
public void AddBootImage( WqlConnectionManager connection, string name, string description, string pathToWim) { try { // Create new boot image package object. IResultObject bootImagePackage = connection.CreateInstance("SMS_BootImagePackage"); // Populate new boot image package properties. bootImagePackage["Name"].StringValue = name; bootImagePackage["Description"].StringValue = description; bootImagePackage["ImagePath"].StringValue = pathToWim; // UNC path required. bootImagePackage["ImageIndex"].IntegerValue = 1; // Index into WIM file for image. // Save new package and new package properties. bootImagePackage.Put(); } catch (SmsException e) { Console.WriteLine(); Console.WriteLine("Failed to create package. Error: " + e.Message); throw; } } |
The sample method has the following parameters:
Parameter |
Type |
Description |
connection |
|
A valid connection to the SMS Provider. |
name |
|
Name for the new boot image package. |
description |
|
Description for the boot image package. |
pathToWIM |
|
UNC path to the image. |
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 Securing Configuration Manager Applications.