Cómo reparar SCCM Offline Servicing: Error Failed to apply updates con Schedule Updates

Desde SCCM 2012 existe la opción Schedule Updates, que nos permite actualizar una imagen de referencia con KBs que tengamos sincronizados previamente en Configuration Manager. Pero, en ocasiones, nos puede dar error al intentar aplicar alguna actualización y debido a ello falla al desmontar la imagen.
Esto nos impedirá seguir usando la opción de Schedule Updates hasta que no desmontemos la imagen manualmente del Windows Server instalado en el Primary Server. Por ello, en este artículo vamos a ver cómo reparar el Error Failed to apply updates en SCCM.
TL;DR
Error SCCM Offline Servicing
Este post es una guía sobre cómo reparar la función Offline Servicing de SCCM para poder continuar inyectando actualizaciones en las imágenes tras el error «Failed to apply one or more updates«.

Para determinar si este es vuestro problema, podéis leer el log OfflineServicingMgr.log. Este log estará en la carpeta Logs dentro de la instalación de System Center Configuration Manager en vuestro Site Server (Primary Server). El error debería ser algo así:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | Image info: Package id ABC00001, Size 4821466 KB, Image path '\\contoso.com\sccm\images\Windows_10_1803.wim', Type: 'OS Image' $<SMS_OFFLINE_SERVICING_MANAGER> Deleting file \\?\D:\ConfigMgr_OfflineImageServicing\ABC00001\ImageMountDir\bootmgr, FAILED, Win32 Error = 5 $<SMS_OFFLINE_SERVICING_MANAGER> Failed to remove previously existing staging folder D:\ConfigMgr_OfflineImageServicing\ABC00001, GLE = 5 $<SMS_OFFLINE_SERVICING_MANAGER> Initialization of schedule processing failed $<SMS_OFFLINE_SERVICING_MANAGER> Processing completed for Schedule with ID 16777255 $<SMS_OFFLINE_SERVICING_MANAGER> STATMSG: ID=7910 SEV=E LEV=M SOURCE="SMS Server" COMP="SMS_OFFLINE_SERVICING_MANAGER" SYS=MyServer.Contoso.com SITE=ABC PID=4176 TID=21720 $<SMS_OFFLINE_SERVICING_MANAGER> Deleting file \\?\D:\ConfigMgr_OfflineImageServicing\ABC00001\ImageMountDir\bootmgr, FAILED, Win32 Error = 5 $<SMS_OFFLINE_SERVICING_MANAGER> Failed to remove the staging folder D:\ConfigMgr_OfflineImageServicing, GLE = 5 $<SMS_OFFLINE_SERVICING_MANAGER> Schedule processing thread stopped~ $<SMS_OFFLINE_SERVICING_MANAGER> Closing the thread handle. $<SMS_OFFLINE_SERVICING_MANAGER> Checking if there are schedule(s) which need to be run at this time. $<SMS_OFFLINE_SERVICING_MANAGER> This Schedule with ID 16777222 does not have a next run time $<SMS_OFFLINE_SERVICING_MANAGER> No more schedules are found to be run at this time or in the future. $<SMS_OFFLINE_SERVICING_MANAGER> Will sleep till a new schedule is created. $<SMS_OFFLINE_SERVICING_MANAGER> No schedule exists which needs to be run anytime in future. $<SMS_OFFLINE_SERVICING_MANAGER> Offline Servicing Manager thread is exiting.~ $<SMS_OFFLINE_SERVICING_MANAGER> |
Reparar error en SCCM Offline Servicing
Como podéis ver, el proceso de DISM no es capaz de desmontar la anterior imagen a la que intentamos inyectar los KBs (posiblemente porque falló la instalación). Para resolver este problema, deberemos abrir un CMD con permisos de administrador:

Y ejecutar el siguiente comando: dism.exe /cleanup-wim
Este comando buscará todas las imágenes que estén en todas las particiones de Windows Server (por lo que no es necesario cambiarse de partición desde el CMD).

Después podremos ver las imágenes montadas con el comando: dism.exe /get-MountedWiminfo

Y desmontar la imágenes con el comando: dism.exe /unmount-Wim /MountDir:<mountDir> /commit

De manera opcional, podemos comprobar la carpeta ConfigMgr_OfflineImageServicing donde estaba montada la imagen para asegurarnos de que ya no se encuentra bloqueada y podemos eliminarla. De no hacerlo, el próximo proceso de Schedule Updates lo hará automáticamente.

Comprobar el log SCCM Offline Servicing reparado
Ahora, deberemos lanzar de nuevo el Schedule Updates sobre la imagen y seguir el log OfflineServicingMgr.log para comprobar que ya puede montar la nueva imagen y aplica las actualizaciones correctamente sobre la imagen de referencia:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | Completed processing image package ABC00001. Status = Success $<SMS_OFFLINE_SERVICING_MANAGER> STATMSG: ID=7904 SEV=I LEV=M SOURCE="SMS Server" COMP="SMS_OFFLINE_SERVICING_MANAGER" SYS=MyServer.Contoso.com SITE=ABC PID=4176 TID=21968 $<SMS_OFFLINE_SERVICING_MANAGER> Create backup copy for image ABC00001 $<SMS_OFFLINE_SERVICING_MANAGER> copying image file '\\contoso.com\sccm\images\Windows_10_1803.wim' to '\\contoso.com\sccm\images\Windows_10_1803.wim.bak' ... $<SMS_OFFLINE_SERVICING_MANAGER> Copy image ( ID ABC00001, size 4821 MB ) $<SMS_OFFLINE_SERVICING_MANAGER> copying file from 'D:\ConfigMgr_OfflineImageServicing\ABC00001\Windows_10_1803.wim' $<SMS_OFFLINE_SERVICING_MANAGER> to '\\contoso.com\sccm\images\Windows_10_1803.wim' .... $<SMS_OFFLINE_SERVICING_MANAGER> Copying (25% complete)... $<SMS_OFFLINE_SERVICING_MANAGER> Copying (50% complete)... $<SMS_OFFLINE_SERVICING_MANAGER> Copying (75% complete)... $<SMS_OFFLINE_SERVICING_MANAGER> Copying (100% complete)... $<SMS_OFFLINE_SERVICING_MANAGER> Deleted the backed up copy of image ''. $<SMS_OFFLINE_SERVICING_MANAGER> Successfully requested image ABC00001 to be updated from its source.~ $<SMS_OFFLINE_SERVICING_MANAGER> STATMSG: ID=7905 SEV=I LEV=M SOURCE="SMS Server" COMP="SMS_OFFLINE_SERVICING_MANAGER" SYS=MyServer.Contoso.com SITE=ABC PID=4176 TID=21968 $<SMS_OFFLINE_SERVICING_MANAGER> Updated history for image package ABC00001 in the database $<SMS_OFFLINE_SERVICING_MANAGER>< Schedule processing succeeded $<SMS_OFFLINE_SERVICING_MANAGER> Processing completed for Schedule with ID 16777256 $<SMS_OFFLINE_SERVICING_MANAGER> STATMSG: ID=7901 SEV=I LEV=M SOURCE="SMS Server" COMP="SMS_OFFLINE_SERVICING_MANAGER" SYS=MyServer.Contoso.com SITE=ABC PID=4176 TID=21968 $<SMS_OFFLINE_SERVICING_MANAGER> Schedule processing thread stopped~ $<SMS_OFFLINE_SERVICING_MANAGER> Closing the thread handle. $<SMS_OFFLINE_SERVICING_MANAGER> Checking if there are schedule(s) which need to be run at this time. $<SMS_OFFLINE_SERVICING_MANAGER> This Schedule with ID 16777222 does not have a next run time $<SMS_OFFLINE_SERVICING_MANAGER> No more schedules are found to be run at this time or in the future. $<SMS_OFFLINE_SERVICING_MANAGER> Will sleep till a new schedule is created. $<SMS_OFFLINE_SERVICING_MANAGER> No schedule exists which needs to be run anytime in future. $<SMS_OFFLINE_SERVICING_MANAGER> Offline Servicing Manager thread is exiting.~ $<SMS_OFFLINE_SERVICING_MANAGER> |
