Preventing overwriting of extra partitions in an MDT task sequence

The other day one of our users used our MDT\WDS process to rebuild his laptop. He’d partitioned his hard drive so that he had a C and D drive and thought that he’d backed up all of his data from his D: drive. Unfortunately, he hadn’t and when the MDT task sequence ran it repartitioned and formatted the drive to just being a single partition. Doh!

Looking around on the web it seems that there are lots of ways to either point MDT to a specific drive and\or partition or add task panes\code to allow you to choose the destination disk. One alternative was to create separate task sequences and remove some of the sections for a new computer. Another way was to add sections to the CustomSettings.ini for each deployment model with an action to change the deployment type from NewComputer to Refresh. However, I think I’ve come up with a better and more simpler way of preserving partitions and just rebuilding Windows.

What I used was a Task Sequence variable in the Preinstall section with a condition to see if the Windows folder exists.

 

If the Windows folder exists then we set the DeploymentType task sequence variable to Refresh and the task sequence will only run a refresh. Otherwise, it will still be NewComputer and run the standard partition and format.

We also need to set the OS to install to a particular drive and partition and not use the entire disk.

 

I’ve tested it and it seems to work correctly, preserving any data on other partitions\drives.

**DISCLAIMER: Always ensure that you back up all data anyway before you rebuild your machine.