운영 체제 배포 작업 순서의 단계를 열거하는 방법How to Enumerate the Steps in an Operating System Deployment Task Sequence
작업 순서 단계 및 그룹을 검색 하는 데 재귀 방법을 사용 하 여 Configuration Manager에서 운영 체제 배포 작업 순서를 열거 합니다.You enumerate an operating system deployment task sequence, in Configuration Manager, by using a recursive method to scan through the task sequence steps and groups.
작업 순서의 단계를 열거 하려면To enumerate the steps in a task sequence
SMS 공급자에 대한 연결을 설정합니다.Set up a connection to the SMS Provider. 자세한 내용은 SMS 공급자 기본 사항을 참조 하세요.For more information, see SMS Provider fundamentals.
올바른 작업 순서 SMS_TaskSequence 개체를 가져옵니다.Obtain a valid task sequence SMS_TaskSequence object. 자세한 내용은 운영 체제 배포 작업 순서를 만드는 방법 을 참조 하세요.For more information, see How to Create an Operating System Deployment Task Sequence
모든 작업 (SMS_TaskSequence_Action) 이름을 표시 하는 단계를 열거 합니다.Enumerate through the steps to display any action (SMS_TaskSequence_Action) names. 재귀를 사용 하 여 발견 된 모든 그룹 (SMS_TaskSequence_Group)에 액세스 하 고 해당 작업을 표시 합니다.Use recursion to access any groups (SMS_TaskSequence_Group) that are found and display their actions.
예제Example
다음 예에서는 작업 순서 내에서 작업 및 그룹을 표시 합니다.The following example displays the actions and groups within a task sequence.
샘플 코드를 호출하는 방법에 대한 자세한 내용은 Configuration Manager 코드 조각 호출을 참조하세요.For information about calling the sample code, see Calling Configuration Manager Code Snippets.
Sub RecurseTaskSequenceSteps(taskSequence, indent)
Dim osdStep
Dim i
' Indent each new group.
for each osdStep in taskSequence.Steps
for i=0 to indent
WScript.StdOut.Write " "
next
If osdStep.SystemProperties_("__CLASS")="SMS_TaskSequence_Group" Then
wscript.StdOut.Write "Group: "
End If
WScript.Echo osdStep.Name
' Recurse into each group found.
If osdStep.SystemProperties_("__CLASS")="SMS_TaskSequence_Group" Then
If IsNull(osdStep.Steps) Then
Wscript.Echo "No steps"
Else
Call RecurseTaskSequenceSteps (osdStep, indent+3)
End If
End If
Next
End Sub
public void RecurseTaskSequenceSteps(
IResultObject taskSequence,
int indent)
{
try
{
// The array of SMS_TaskSequence_Steps.
List<IResultObject> steps = taskSequence.GetArrayItems("Steps");
foreach (IResultObject ro in steps)
{
for (int i = 0; i < indent; i++)
{
Console.Write(" ");
}
if (ro["__CLASS"].StringValue == "SMS_TaskSequence_Group")
{
Console.Write("Group: ");
}
Console.WriteLine(ro["Name"].StringValue);
// Child groups that are found. Use recursion to view them.
if (ro["__CLASS"].StringValue == "SMS_TaskSequence_Group")
{
this.RecurseTaskSequenceSteps(ro, indent + 3);
}
}
}
catch (SmsException e)
{
Console.WriteLine("Failed To enumerate task sequence items: " + e.Message);
throw;
}
}
예제 메서드에는 다음과 같은 매개 변수가 포함되어 있습니다.The example method has the following parameters:
매개 변수Parameter | TypeType | DescriptionDescription |
---|---|---|
taskSequence |
- 관리 코드: IResultObject - Managed: IResultObject -VBScript: SWbemObject- VBScript: SWbemObject |
유효한 작업 순서 ( SMS_TaskSequence )입니다.A valid task sequence (SMS_TaskSequence ). 그룹이이 작업 순서에 추가 됩니다.The group is added to this task sequence. |
indent |
- 관리 코드: Integer - Managed: Integer - VBScript: Integer - VBScript: Integer |
들여쓰기는 자식 그룹의 콘솔 출력 공간을 확보 하는 데 사용 됩니다.Indent is used to space console output for child groups. |
코드 컴파일Compiling the Code
이 c # 예제에는 다음이 필요 합니다.This C# example requires:
네임스페이스Namespaces
시스템System
System.Collections.GenericSystem.Collections.Generic
System.TextSystem.Text
Microsoft.ConfigurationManagement.ManagementProviderMicrosoft.ConfigurationManagement.ManagementProvider
Microsoft.ConfigurationManagement.ManagementProvider.WqlQueryEngineMicrosoft.ConfigurationManagement.ManagementProvider.WqlQueryEngine
어셈블리Assembly
microsoft.configurationmanagement.managementprovidermicrosoft.configurationmanagement.managementprovider
adminui.wqlqueryengineadminui.wqlqueryengine
강력한 프로그래밍Robust Programming
오류 처리에 대한 자세한 내용은 Configuration Manager 오류 정보를 참조하세요.For more information about error handling, see About Configuration Manager Errors.
.NET Framework 보안.NET Framework Security
Configuration Manager 응용 프로그램을 보호 하는 방법에 대 한 자세한 내용은 역할 기반 관리 Configuration Manager를 참조 하세요.For more information about securing Configuration Manager applications, see Configuration Manager role-based administration.
참고 항목See Also
개체 개요 운영 체제 배포 작업 순서 동작을 추가 하는 방법 Objects overview How to Add an Operating System Deployment Task Sequence Action
관리 코드를 사용 하 여 Configuration Manager에서 SMS 공급자에 연결 하는 방법 How to Connect to an SMS Provider in Configuration Manager by Using Managed Code
WMI를 사용 하 여 Configuration Manager에서 SMS 공급자에 연결 하는 방법 How to Connect to an SMS Provider in Configuration Manager by Using WMI
작업 순서 개요Task sequence overview