How to Add a Boot Image from a WIM File in Configuration Manager
You add a boot image from a Windows Image (WIM) file to Configuration Manager by creating an instance of SMS_BootImagePackage. 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.
Note
When the boot image is updated, for example, when a 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 SMS Provider fundamentals.
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.
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
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 |
- Managed: WqlConnectionManager - VBScript: SWbemServices |
A valid connection to the SMS Provider. |
name |
- Managed: String - VBScript: String |
Name for the new boot image package. |
description |
- Managed: String - VBScript: String |
Description for the boot image package. |
pathToWIM |
- Managed: Integer - VBScript: Integer |
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.
.NET Framework Security
For more information about securing Configuration Manager applications, see Configuration Manager role-based administration.
See Also
How to Assign a Package to a Distribution Point
How to add a Windows Driver to a Configuration Manager Boot Image Package
How to Assign a Package to a Distribution Point
About image management