You enumerate the available operating system deployment task sequences, in Microsoft System Center Configuration Manager 2007, by querying the available task sequence packages. Configuration Manager 2007 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

  1. Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.

  2. Query the SMS Provider for the available instances of SMS_TaskSequencePackage.

  3. 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.

Visual Basic Script  Copy Code
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
C#  Copy Code
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();
}
}

The example method has the following parameters:

Parameter Type Description

connection

  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

A valid connection to the SMS Provider.

Compiling the Code

The C# example requires:

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.