Partager via


How to Move a Step to a Different Operating System Deployment Task Sequence Group

Applies To: System Center Configuration Manager 2007, System Center Configuration Manager 2007 R2, System Center Configuration Manager 2007 R3, System Center Configuration Manager 2007 SP1, System Center Configuration Manager 2007 SP2

You move a step (an action or a group) from one operating system deployment task sequence group to another, in Microsoft System Center Configuration Manager 2007, 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

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

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

  3. Add the step to the target group. For more information, see How to Add a Step to an Operating System Deployment Group.

  4. Reorder the step within the target group array property as necessary. For more information, see How to Reorder an Operating System Deployment Task Sequence

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

Security

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

See Also

Concepts

Configuration Manager Operating System Deployment
Configuration Manager Objects
Configuration Manager Programming Fundamentals
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
Operating System Deployment Task Sequencing