You read a task sequence from a task sequence package, in System Center 2012 Configuration Manager, 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
-
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 SMS_TaskSequencePackage that you want to load the sequence from.
-
Call the SMS_TaskSequencePackage class GetSequence method to get the SMS_TaskSequence object.
-
Make changes to the task sequence and put them back into the package by using SetSequence.
Example
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"). _ inParameters.SpawnInstance_() ' 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; try { 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); throw; } } |
The example method has the following parameters:
Parameter | Type | Description |
---|---|---|
connection |
|
|
Compiling the Code
This 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 Securing Configuration Manager Applications.
See Also
Tasks
How to Connect to an SMS Provider in Configuration Manager by Using Managed CodeHow to Connect to an SMS Provider in Configuration Manager by Using WMI
How to Create an Operating System Deployment Task Sequence Package
How to Enumerate the Available Operating System Deployment Task Sequences
Concepts
Configuration Manager Operating System DeploymentConfiguration Manager Objects
Configuration Manager Programming Fundamentals
Operating System Deployment Task Sequencing