How to Enumerate the Available Operating System Deployment Task Sequences
Updated: November 1, 2013
Applies To: System Center 2012 Configuration Manager, System Center 2012 Configuration Manager SP1, System Center 2012 R2 Configuration Manager
You enumerate the available operating system deployment task sequences, in System Center 2012 R2 Configuration Manager, by querying the available task sequence packages. System Center 2012 R2 Configuration Manager does not maintain instances of the SMS_TaskSequence class for task sequences, but there is one instance of the SMS_TaskSequencePackage class for each task sequence.
Note |
|---|
Several properties are lazy and you must get the object instance before you can access the properties. |
You can also access individual task sequence packages by using the PackageID key property. For an example, see How to Read a Configuration Manager Object by Using Managed Code. After you have the task sequence package, you must create an SMS_TaskSequence object for the task sequence before you can change it. For more information, see How to Read a Task Sequence from a Task Sequence Package.
To enumerate the available task sequence packages
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
Query the SMS Provider for the available instances of SMS_TaskSequencePackage.
Display the required properties for each task sequence package returned by the query.
Example
The following example method queries the SMS Provider for the available instance of (SMS_TaskSequencePackage). To retrieve the lazy properties, the example gets the entire object from the SMS Provider.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub EnumerateTaskSequencePackages(connection)
Set taskSequencePackages= connection.ExecQuery("Select * from SMS_TaskSequencePackage")
For Each package in taskSequencePackages
WScript.Echo package.Name
WScript.Echo package.Sequence
Next
End Sub
public void EnumerateTaskSequencePackages( WqlConnectionManager connection) { IResultObject taskSequencePackages = connection.QueryProcessor.ExecuteQuery("select * from SMS_TaskSequencePackage"); foreach (IResultObject ro in taskSequencePackages) { ro.Get(); // Get the lazy properties - Sequence property contains the Task sequence XML. Console.WriteLine(ro["Name"].StringValue); Console.WriteLine(ro["Sequence"].StringValue); Console.WriteLine(); } }
Compiling the Code
The C# example requires:
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
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 Securing Configuration Manager Applications.
Configuration Manager Operating System Deployment
Configuration Manager Objects
Configuration Manager Programming Fundamentals
How to Connect to an SMS Provider in Configuration Manager by Using Managed Code
How to Connect to an SMS Provider in Configuration Manager by Using WMI
How to Create an Operating System Deployment Task Sequence Package
How to Read a Task Sequence from a Task Sequence Package
Operating System Deployment Task Sequencing

The example method has the following parameters:
Parameter
Type
Description
connection
Managed: WqlConnectionManager
VBScript: SWbemServices
A valid connection to the SMS Provider.