How to Move a Step to a Different Operating System Deployment Task Sequence Group
You move a step (an action or a group) from one operating system deployment task sequence group to another, in Configuration Manager, by adding the step to the target group and then by deleting the step from the source group.
To move a step from one group to another
Set up a connection to the SMS Provider. For more information, see SMS Provider fundamentals.
Get the source and target SMS_TaskSequenceGroup objects. Copy a step that you want to add the step to. For more information, see How to Create an Operating System Deployment Task Sequence Group.
Add the step to the target group. For more information, see How to Add a Step to an Operating System Deployment Group.
Reorder the step within the target group array property as necessary. For more information, see How to Re-order an Operating System Deployment Task Sequence
Delete the step from the source group. For more information, see How to Remove a Step From an Operating System Deployment Group.
Example
The following example method moves a step from one task sequence group to another.
You will need the code snippet in How to Remove a Step From an Operating System Deployment Group to run this example.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub MoveActionToGroup( taskSequenceStep, sourceGroup,targetGroup)
Dim steps
Dim groupSteps
Steps = Array(targetGroup.Steps)
If IsNull(targetGroup.Steps) Then
groupSteps = Array(taskSequenceStep)
targetGroup.Steps = groupSteps
Else
ReDim steps (UBound (targetGroup.Steps)+1)
targetGroup.Steps(UBound(steps))=taskSequenceStep
End If
Call RemoveActionFromGroup(sourceGroup,taskSequenceStep.Name)
End Sub
public void MoveActionToGroup(
IResultObject taskSequenceStep,
IResultObject sourceGroup,
IResultObject targetGroup)
{
try
{
// Add the step to the target group.
// Note. You can use MoveTaskSequenceStepUp and MoveTaskSequenceStepDown
// to place the step in the target group.
List<IResultObject> groupSteps = targetGroup.GetArrayItems("Steps");
groupSteps.Add(taskSequenceStep);
targetGroup.SetArrayItems("Steps", groupSteps);
// Remove action from the source group.
this.RemoveActionFromGroup(sourceGroup, taskSequenceStep["Name"].StringValue);
}
catch (SmsException e)
{
Console.WriteLine("Failed to create Task Sequence: " + e.Message);
throw;
}
}
The example method has the following parameters:
Parameter | Type | Description |
---|---|---|
taskSequenceStep |
- Managed: IResultObject - VBScript: SWbemObject |
A valid task sequence step (Group or action) (SMS_TaskSequence_Step). |
sourceGroup |
- Managed: IResultObject - VBScript: SWbemObject |
The group SMS_TaskSequenceGroup the step is copied from. |
targetGroup |
- Managed: IResultObject - VBScript: SWbemObject |
The group SMS_TaskSequenceGroup the step is copied to. |
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.
.NET Framework Security
For more information about securing Configuration Manager applications, see Configuration Manager role-based administration.
See Also
Objects overview
How to Add a Step to an Operating System Deployment Group
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 Group
How to Remove a Step From an Operating System Deployment Group
Task sequence overview