OS Deployment failing due to left over junk from MDT – Part II

(Last updated on November 30, 2018)

OS Deployment failing due to left over junk from MDT – Part II

There is a small bug in MDT 2010 which sometimes leaves junk in the system after a successful Deployment (See Part I).

So to clean up the system, we usually add this script to App Deploy.

@Echo off 

echo %date% %time% >> %windir%TempPOSTMDT.LOG
rmdir /Q /S C:MININT >> %windir%TempPOSTMDT.LOG
rmdir /Q /S c:SYSPREP >> %windir%TempPOSTMDT.LOG
rmdir /Q /S C:_SMSTaskSequence >> %windir%TempPOSTMDT.LOG

bcdedit /set {default} recoveryenabled NO >> %windir%TempPOSTMDT.LOG
bcdedit /set {default} bootstatuspolicy ignoreallfailures >> %windir%TempPOSTMDT.LOG

# End of Script

You may want to skip the last two lines with bcdedit. They will just prevent windows from starting the Repair Windows setup when there was a problem with shutdown or startup. Which usually just confuses the end users.

More info: http://download.microsoft.com/download/9/c/5/9c5b2167-8017-4bae-9fde-d599bac8184a/BCDedit_reff.docx

Adding a Package
Add the script as a Legacy package like this;

Notice, that we ignore the exit code for this task. We just assume it always succeeded.

Creating a Target
When an OS installation is completed with MDT, all the logfiles are moved to %WINDIR%TempDeploymentLogs so you can create a Target like this to only run the cleanup after the OS install is done.

Target: Files %SystemRoot% WindowstempDeploymentlogsBDD.Log

If you choose to not create a target like that, you may risk running the cleanup task too early, before the installation is done.

So, in that case, make sure to move the package to the end of the list. Which should hopefully give the system enough time to finish the OS installation.

And then create a Deployment for that Package with the Target.

It will now run on all the previously installed clients (hit by the GPO) cleaning up the left over MDT junk and also on all new installations.

Tags: , ,

Back to Blog