An operating system deployment task sequence group, in System Center 2012 Configuration Manager, can be added to a task sequence by creating an instance of the SMS_TaskSequence_Group class. The group is then added to the list of steps of the task sequence. The list of steps is an array of the SMS_TaskSequence_Step derived classes. The array is stored in the task sequence, SMS_TaskSequence, Steps property.
To create a task sequence group
-
Set up a connection to the SMS Provider. For more information, see About the SMS Provider in Configuration Manager.
-
Obtain a valid task sequence (SMS_TaskSequence) object. For more information, see How to Create an Operating System Deployment Task Sequence.
-
Create an instance of the SMS_TaskSequence_Group class.
-
Populate the group with the appropriate properties.
-
Update the task sequence Steps property with the new group.
Example
The following example method adds a new group to the supplied task sequence. Because the group is added to the end of the task sequence Steps array, you might want to reorder its position. For more information, see How to Reorder an Operating System Deployment Task Sequence.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Visual Basic Script | Copy Code |
---|---|
Sub AddTaskSequenceGroup(connection, taskSequence, name, description) Dim group ' Create and populate the group. Set group = connection.Get("SMS_TaskSequence_Group").SpawnInstance_ group.Name=name group.Description=description group.Enabled=True group.ContinueOnError=False ' Resize the task sequence steps array to hold the new group. ReDim steps (UBound (taskSequence.Steps)+1) ' Add the group. taskSequence.Steps(UBound(steps))=group End Sub |
C# | Copy Code |
---|---|
public IResultObject AddTaskSequenceGroup( WqlConnectionManager connection, IResultObject taskSequence, string name, string description) { try { // Create the new group. IResultObject ro = connection.CreateEmbeddedObjectInstance("SMS_TaskSequence_Group"); ro["Name"].StringValue = name; ro["Description"].StringValue = description; ro["Enabled"].BooleanValue = true; ro["ContinueOnError"].BooleanValue = false; // Add the group to the task sequence. List<IResultObject> array = taskSequence.GetArrayItems("Steps"); array.Add(ro); // Add the new group to the end of the current steps. taskSequence.SetArrayItems("Steps", array); return ro; } catch (SmsException e) { Console.WriteLine("Failed to create Task Sequence: " + e.Message); throw; } } |
This example method has the following parameters:
Parameter | Type | Description |
---|---|---|
connection |
|
A valid connection to the SMS Provider. |
taskSequence |
|
A valid task sequence (SMS_TaskSequence). The group is added to this task sequence. |
Name |
|
A name for the new group. |
Description |
|
A description for the new group. |
Parameter | Description |
---|---|
connection |
A WqlConnectionManager object that is a valid connection to the SMS Provider. |
taskSequence |
An IResultObject that is a valid task sequence (SMS_TaskSequence). The group is added to this task sequence. |
name |
A string name for the new group. |
description |
A string description for the new group. |
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 Add a Step to an Operating System Deployment GroupHow 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
Concepts
Configuration Manager Operating System DeploymentConfiguration Manager Objects
Configuration Manager Programming Fundamentals
Operating System Deployment Task Sequencing