| title | Remove a Step from an OS Deployment Group |
|---|---|
| description | Deletes a step from an operating system deployment task sequence group by deleting the step from the group's list of task sequence steps. |
| ms.date | 09/20/2016 |
| ms.subservice | sdk |
| ms.topic | how-to |
| ms.collection | tier3 |
In Configuration Manager, you delete a step (an action or a group) from an operating system deployment task sequence group by deleting the step from the group's list of task sequence steps.
-
Set up a connection to the SMS Provider. For more information, see SMS Provider fundamentals.
-
Get the SMS_TaskSequence_Group object that you want to add the step to. For more information, see How to Create an Operating System Deployment Task Sequence Group.
-
Remove the action from the SMS_TaskSequence_Group.Steps array property.
The following example method removes an action from a task sequence group.
For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub RemoveActionFromGroup(taskSequenceGroup, actionName)
Dim i
If taskSequenceGroup.SystemProperties_("__CLASS")<>"SMS_TaskSequence_Group" Then
wscript.echo "Not a group"
return
End If
Dim newArray
Dim actionStep
newArray = Array(taskSequenceGroup.Steps)
ReDim newArray(UBound(taskSequenceGroup.Steps))
i=0
for each actionStep in taskSequenceGroup.Steps
If actionStep.Name = actionName and _
actionStep.SystemProperties_("__SUPERCLASS") = "SMS_TaskSequence_Action" Then
ReDim preserve newArray(UBound(newArray)-1) ' shrink the Array
else
wscript.echo actionStep.Name
Set newArray(i)=actionStep ' copy it
i=i+1
End If
Next
taskSequenceGroup.Steps=newArray
End Subpublic void RemoveActionFromGroup(
IResultObject taskSequenceGroup,
string actionName)
{
try
{
if (taskSequenceGroup["__CLASS"].StringValue != "SMS_TaskSequence_Group")
{
throw new System.InvalidOperationException("Not a group");
}
List<IResultObject> groupSteps = taskSequenceGroup.GetArrayItems("Steps");
IResultObject actionFound = null;
foreach (IResultObject actionStep in groupSteps)
{
if (actionStep["Name"].StringValue == actionName && actionStep["__SUPERCLASS"].StringValue == "SMS_TaskSequence_Action")
{
actionFound = actionStep;
break;
}
}
groupSteps.Remove(actionFound);
taskSequenceGroup.SetArrayItems("Steps", groupSteps);
}
catch (SmsException e)
{
Console.WriteLine("Failed to remove action: " + e.Message);
throw;
}
}The example method has the following parameters:
| Parameter | Type | Description |
|---|---|---|
taskSequenceGroup |
- Managed: IResultObject - VBScript: SWbemObject |
The task sequence group containing the action to be deleted. |
actionName |
- Managed: String- VBScript: String |
The name of the action to be deleted. This can be obtained from the SMS_TaskSequenceAction.Name property. |
This C# example requires:
System
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
For more information about error handling, see About Configuration Manager Errors.
For more information about securing Configuration Manager applications, see Configuration Manager role-based administration.
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 Move a Step to a Different Operating System Deployment Task Sequence Group How to Create an Operating System Deployment Task Sequence Group Task sequence overview