您可以將步驟 (動作或群組) 從一個作系統部署工作順序群組移至另一個作系統部署工作順序群組,Configuration Manager 將步驟新增至目標群組,然後從來源群組中刪除步驟。
將步驟從一個群組移到另一個群組
設定與SMS提供者的連線。 如需詳細資訊,請 參閱SMS提供者基本概念。
取得來源和目標 SMS_TaskSequenceGroup 物件。 複製您要新增步驟的步驟。 如需詳細資訊,請參閱 如何建立作系統部署工作順序群組。
將步驟新增至目標群組。 如需詳細資訊,請參閱 如何將步驟新增至作系統部署群組。
視需要重新排序目標群組數位屬性內的步驟。 如需詳細資訊,請參閱 如何重新排序作系統部署工作順序
從來源群組中刪除步驟。 如需詳細資訊,請 參閱如何從作系統部署群組移除步驟。
範例
下列範例方法會將步驟從一個工作順序群組移至另一個工作順序群組。
您需要 如何從作系統部署群組移除步驟 中的代碼段,才能執行此範例。
如需呼叫範例程式代碼的相關信息,請參閱呼叫 Configuration Manager 代碼段。
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;
}
}
範例方法具有下列參數:
| 參數 | Type | 描述 |
|---|---|---|
taskSequenceStep |
-管理: IResultObject- VBScript: SWbemObject |
(群組或動作) (SMS_TaskSequence_Step ) 的有效工作順序步驟。 |
sourceGroup |
-管理: IResultObject- VBScript: SWbemObject |
複製步驟的來源群組 SMS_TaskSequenceGroup 。 |
targetGroup |
-管理: IResultObject- VBScript: SWbemObject |
複製步驟的群組 SMS_TaskSequenceGroup 。 |
正在編譯程式碼
此 C# 範例需要:
命名空間
系統
System.Collections.Generic
System.Text
Microsoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
組件
microsoft.configurationmanagement.managementprovider
adminui.wqlqueryengine
健全的程式設計
如需錯誤處理的詳細資訊,請參閱關於 Configuration Manager 錯誤。
.NET Framework 安全性
如需保護 Configuration Manager 應用程式的詳細資訊,請參閱 Configuration Manager 角色型系統管理。
另請參閱
物件概觀 如何使用受控程序代碼如何使用 WMI 如何建立作系統部署工作順序群組,將步驟新增至作系統部署群組如何在 Configuration Manager 中聯機到 SMS 提供者如何在 Configuration Manager 中聯機到 SMS 提供者如何從作系統部署群組工作順序概觀中移除步驟