I recently came across an issue where a Windows 10 (1511) task sequence would hang during a software update task. The patch being installed at the time didn’t appear to be consistently the same, so I ruled out an issue with the update. After some digging I found this article which nailed the issue down to a crashing Windows Update service.
The suggested work around appears to work, but is a manual process. The script below automates the same process.Basically it sits in the background and checks the wuauserv service every 60 seconds. If it is in a StopPending state, it waits another 120 seconds, and if still in the same state, resets both the wuauserv and ccmexec processes.
Note that the task sequence progress bar can hang quite a while before the Windows Update service actually crashes. It seems as though the updates keep installing in the background.
This can be added to an SCCM package and launched from a Run Command Line task. Using start from within the command line will launch it in the background i.e.
cmd /c start powershell -executionpolicy bypass .SccmWin10WuWorkaround.ps1
Note that this might still error the task, so select Continue on error for the Install Software Updates step. I have multiple passes in my build and capture task to retry any failures.