调试任务序列Debug a task sequence

适用范围: Configuration Manager (Current Branch)Applies to: Configuration Manager (current branch)

从版本 1906 开始,任务序列调试器是一种新型故障排除工具。Starting in version 1906, the task sequence debugger is a new troubleshooting tool. 在调试模式下将任务序列部署到小集合。You deploy a task sequence in debug mode to a small collection. 这样便可通过可控方式单步执行任务序列,以帮助进行故障排除和调查。It lets you step through the task sequence in a controlled manner to aid troubleshooting and investigation. 调试器当前与任务序列引擎在同一设备上运行,它不是远程调试器。The debugger currently runs on the same device as the task sequence engine, it's not a remote debugger.

备注

在该 Configuration Manager 版本中,任务序列调试器是预发行功能。In this version of Configuration Manager, the task sequence debugger is a pre-release feature. 若要启用此功能,请参阅预发行功能To enable it, see Pre-release features.

必备条件Prerequisites

  • 更新目标设备上的 Configuration Manager 客户端Update the Configuration Manager client on the target device

  • 以本地“管理员”组中的用户身份登录到目标设备 。Sign in to the target device as a user in the local Administrators group. 仅为管理员运行调试器。The debugger only runs for administrators.

  • 更新与任务序列关联的启动映像,以确保其具有最新的客户端版本Update the boot image associated with the task sequence to make sure it has the latest client version

启动工具Start the tool

  1. 在 Configuration Manager 工作区中,转到“软件库”工作区,展开“操作系统”,选择“任务序列” 。In the Configuration Manager console, go to the Software Library workspace, expand Operating Systems, and select Task Sequences.

  2. 选择任务序列。Select a task sequence. 在功能区的部署组中,选择“调试” 。In the Deployment group of the ribbon, select Debug.

    提示

    或者,在部署任务序列的集合或计算机对象上将变量“TSDebugMode”设置为 TRUEAlternatively, set the variable TSDebugMode to TRUE on a collection or computer object to which the task sequence is deployed. 设置了此变量的任何设备都会将部署给它的所有任务序列置于调试模式下。Any device that has this variable set will put any task sequence deployed to it into debug mode.

  3. 创建调试部署。Create a debug deployment. 部署设置与常规任务序列部署相同。The deployment settings are the same as a normal task sequence deployment. 有关详细信息,请参阅 Deploy a task sequenceFor more information, see Deploy a task sequence.

    备注

    只能为调试部署选择一个小集合。You can only select a small collection for a debug deployment. 它仅显示包含 10 个或更少成员的设备集合。It only displays device collections with 10 or less members.

自版本 1910 开始,使用新的任务序列变量 TSDebugOnError,以便在任务序列返回错误时自动启动调试程序 。Starting in version 1910, use the new task sequence variable TSDebugOnError to automatically start the debugger when the task sequence returns an error. 有关详细信息,请参阅任务序列变量 - TSDebugOnErrorFor more information, see Task sequence variables - TSDebugOnError.

使用此工具Use the tool

任务序列在设备上运行时,“任务序列调试器”窗口将打开,类似于以下屏幕截图:When the task sequence runs on the device, the Task Sequence Debugger window opens similar to the following screenshot:

任务序列调试器的屏幕截图

调试器包含以下控件:The debugger includes the following controls:

  • 步骤:从“当前”位置,仅运行任务序列中的下一步 。Step: From the current position, run only the next step in the task sequence.

    备注

    任务序列处于调试模式时,如果某个步骤返回严重错误,则任务序列不会按正常情况那样失败。When the task sequence is in debug mode, if a step returns a fatal error, the task sequence doesn't fail as normal. 此行为允许你在进行外部更改后重试步骤。This behavior gives you the option to retry a step after you make an external change.

  • 运行:从“当前” 位置,正常运行任务序列到结束或下一个“中断”点 (如果步骤失败)。Run: From the current position, run the task sequence normally to the end, the next break point, or if a step fails. 使用此操作之前,请确保使用“设置中断”操作设置断点 。Before you use this action, make sure to set any break points with the Set Break action.

  • 设置当前:在调试器中选择一个步骤,然后选择“设置当前” 。Set Current: Select a step in the debugger and then select Set Current. 此操作将“当前”指针移动到该步骤 。This action moves the current pointer to that step. 此操作允许跳过步骤或向后移动。This action allows you to skip steps or move backwards.

    警告

    当你更改序列中的当前位置时,调试器不会考虑步骤的类型。The debugger doesn't consider the type of step when you change the current position in the sequence. 某些步骤可能会设置后续步骤进行条件评估时所需的任务序列变量。Some steps may set task sequence variables that are required for condition evaluation by later steps. 如果运行顺序颠倒,某些步骤可能会失败或对设备造成重大损坏。If run out of order, some steps may fail or cause significant damage to a device. 使用此选项需要自担风险。Use this option at your own risk.

  • 设置中断:在调试器中选择一个步骤,然后选择“设置中断” 。Set Break: Select a step in the debugger and then select Set Break. 此操作将在调试器中添加“中断”点 。This action adds a break point in the debugger. “运行”任务序列时,它会在“中断”处停止 。When you Run the task sequence, it stops at a break.

    • 使用“运行”操作之前,请设置断点 。Before you use the Run action, set break points.

    • 从版本 1910 开始,如果你在调试程序中创建断点,随后任务序列重新启动计算机,则调试程序将在重新启动后保留断点。Starting in version 1910, if you create a break point in the debugger, and then the task sequence restarts the computer, the debugger keeps your break points after restart.

    • 在版本 1906 中,计算机重新启动后不会保存断点,和重新启动计算机步骤的情况一样。In version 1906, break points aren't saved after the computer restarts, like with the Restart Computer step. 例如,如果从软件中心启动用于映像任务序列的调试器,则不应在 Windows PE 阶段中设置中断。For example, if you start the debugger from Software Center for an imaging task sequence, don't set breaks in the Windows PE phase. 计算机重新启动到 Windows PE 时,调试器会暂停任务序列,以便可以设置中断。When the computer restarts into Windows PE, the debugger pauses the task sequence so that you can set breaks.

  • 清除所有中断:删除所有断点。Clear All Breaks: Remove all break points.

  • 日志文件:使用 CMTrace 打开当前任务序列日志文件 smsts.log 。Log File: Opens the current task sequence log file, smsts.log, with CMTrace. 当任务序列引擎在“等待调试器”时,可以看到日志项目。You can see log entries when the task sequence engine is "Waiting for the debugger."

  • Cmd 提示:在 Windows PE 中,打开命令提示符。Cmd Prompt: In Windows PE, opens a command prompt.

  • 取消:关闭调试器,使任务序列失败。Cancel: Close the debugger, and fail the task sequence.

  • 退出:断开并关闭调试器,但任务序列继续正常运行。Quit: Detach and close the debugger, but the task sequence continues to run normally.

“任务序列变量”窗口显示任务序列环境中所有变量的当前值 。The Task Sequence Variables window shows the current values for all variables in the task sequence environment. 有关详细信息,请参阅任务序列变量For more information, see Task sequence variables. 如果结合使用设置任务序列变量步骤和选项“不显示此值”,则调试器不会显示变量值 。If you use the Set Task Sequence Variable step with the option to Do not display this value, the debugger doesn't display the variable value. 无法编辑调试器中的变量值。You can't edit the variable values in the debugger.

备注

某些任务序列变量仅供内部使用,不在参考文档中列出。Some task sequence variables are for internal use only, and not listed in the reference documentation.

任务序列调试器在重新启动计算机步骤后继续运行,但需要重新创建断点。The task sequence debugger continues to run after a Restart Computer step, but you need to recreate any break points. 即使任务序列可能没有相应要求,但由于调试器需要用户交互,你仍需要登录到 Windows 才能继续。Even though the task sequence may not require it, since the debugger requires user interaction, you need to sign in to Windows to continue. 如果在一小时后未登录,并在这种情况下继续调试,则任务序列将失败。If you don't sign in after one hour to continue debugging, the task sequence fails.

它还使用运行任务序列步骤进入子任务序列。It also steps into a child task sequence with the Run Task Sequence step. “调试器”窗口会在显示主要任务序列步骤的同时显示子任务序列步骤。The debugger window shows the steps of the child task sequence along with the main task sequence.

已知问题Known issues

如果通过多个部署向同一设备执行常规部署和调试部署,则任务序列调试器可能无法启动。If you target both a normal deployment and debug deployment to the same device through multiple deployments, the task sequence debugger may not launch.

另请参阅See also