Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
You add an operating system install package to Configuration Manager by creating and populating an instance of SMS_OperatingSystemInstallPackage.
To add an operating system install package
Set up a connection to the SMS Provider. For more information, see SMS Provider fundamentals.
Create an instance of SMS_OperatingSystemInstallPackage.
Set at least the Name, PkgSourceFlag, and PkgSourcePath properties.
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.
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
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.
.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
About image management