You read a task sequence from a task sequence package, in Microsoft System Center Configuration Manager 2007, by calling the SMS_TaskSequencePackage class GetSequence method. GetSequence returns an SMS_TaskSequence object that you can change and then put back in the package by using the SetSequence method. For an example of using SetSequence, see How to Create an Operating System Deployment Task Sequence Package.

To read a task sequence from a task sequence package

  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 SMS_TaskSequencePackage that you want to load the sequence from.

  3. Call the SMS_TaskSequencePackage class GetSequence method to get the SMS_TaskSequence object.

  4. Make changes to the task sequence and put them back into the package by using SetSequence.


The following example method returns the task sequence object (SMS_TaskSequence) from the supplied package.

For information about calling the sample code, see Calling Configuration Manager Code Snippets.

Visual Basic Script  Copy Code
Function ReadTaskSequence(connection, taskSequencePackage)
	' Get the parameters object.
	Set packageClass = connection.Get("SMS_TaskSequencePackage")
	Set objInParam = packageClass.Methods_("GetSequence"). _

	' Add the input parameters.
	 objInParam.Properties_.Item("TaskSequencePackage") =  taskSequencePackage

	' Get the sequence.
	 Set objOutParams = connection.ExecMethod("SMS_TaskSequencePackage", "GetSequence", objInParam)
	 Set ReadTaskSequence = objOutParams.TaskSequence
End Function
C#  Copy Code
public IResultObject ReadTaskSequence(
	WqlConnectionManager connection, 
	IResultObject taskSequencePackage)
	IResultObject taskSequence = null;
		Dictionary<string, object> parameters = new Dictionary<string, object>();
		parameters.Add("TaskSequencePackage", taskSequencePackage);

		IResultObject outParams = connection.ExecuteMethod("SMS_TaskSequencePackage", "GetSequence", parameters);
		taskSequence = outParams.GetSingleItem("TaskSequence");

		return taskSequence;
	catch (Exception e)
		Console.WriteLine("failed to hydrate: " + e.Message);

The example method has the following parameters:

Parameter Type Description


  • Managed: WqlConnectionManager

  • VBScript: SWbemServices

  • A valid connection to the SMS Provider.

Compiling the Code

This C# example requires:










Robust Programming

For more information about error handling, see About Configuration Manager Errors.


For more information about securing Configuration Manager applications, see About Securing Configuration Manager Applications.

See Also

Send comments about this topic to Microsoft.