We've run into some trouble setting up Surface 3s with MDT 2013. Apparently there is a bug in the ZTIWinRE.wsf script, which causes it to copy winre.wim to the EFI system partition rather than the Recovery partition.
https://social.technet.microsoft.com/Forums/en-US/22cb4d44-4215-483e-8bdc-b13d9d27725b/what-partition-does-mdt-2012-place-winre-on?forum=mdt#5e33d5d7-5ee4-432f-af65-710f08e99f72
In addition to it being a nuisance, you are unable to enable bitlocker without a properly configured recovery partition.
Which makes me wonder: am I the only person in the world trying to image Surfaces and enable Bitlocker? I can't imagine that that is the case. So how is everyone else doing it?
After discovering that ZTIWinRE wasnt working, I scratched around for a few days and came up with this (below). I set conditions on ZTIWinRE to only run if IsUEFI=False, and this script ZTIWinRE_UEFI.wsf if IsUEFI=True. I had a hard time making any
sense out of the ZTIDiskUtility.vbs functions, so theres probably an easier way to do it.
<job id="ZTIWinRE_UEFI"><script language="VBScript" src="ZTIUtility.vbs"/><script language="VBScript" src="ZTIDiskUtility.vbs"/><script language="VBScript">
' //----------------------------------------------------------------------------
' //
' // File: ZTIWinRE_MDT_UEFI
' //
' // Purpose: Sets Recovery Environment
' //
' // Usage: cscript ZTIWinRE_UEFI
' //
' //----------------------------------------------------------------------------
'//----------------------------------------------------------------------------
'// Global constant and variable declarations
'//----------------------------------------------------------------------------
'Option Explicit
Dim iRetVal
Dim sArchitecture, colVolumes, objVolume
Dim strREDriveLetter, strSource, strDestFolder, strDestFile
'//----------------------------------------------------------------------------
'// End declarations
'//----------------------------------------------------------------------------
'//----------------------------------------------------------------------------
'// Main routine
'//----------------------------------------------------------------------------
iRetVal = ZTIProcess
ProcessResults iRetVal
'On Error Goto 0
'//---------------------------------------------------------------------------
'//
'// Function: ZTIProcess()
'// Return: Success - 0
'// Failure - non-zero
'//
'// Purpose: Perform main ZTI processing
'//
'//---------------------------------------------------------------------------
Function ZTIProcess()
If UCase(oEnvironment.Item("PrepareWinRE")) <> "YES" then
oLogging.CreateEntry "WinRE is not enabled, Skip.", LogTypeInfo
Main = SUCCESS
Exit Function
End If
oLogging.CreateEntry "---------------- Initialization ----------------", LogTypeInfo
oLogging.CreateEntry "Build = " & oEnvironment.Item("OSCurrentVersion"), LogTypeInfo
If Left(oEnvironment.Item("OSCurrentVersion"),3) < "6.1" then
oLogging.CreateEntry "WinRE is not supported on Vista or Older. Skip.", LogTypeInfo
Main = SUCCESS
Exit Function
End If
sArchitecture= oEnvironment.Item("ImageProcessor")
If sArchitecture = "" then
sArchitecture = oEnvironment.Item("Architecture")
oLogging.CreateEntry "ImageProcessor not set, will boot into Windows PE architecture " & sArchitecture, LogTypeInfo
Else
oLogging.CreateEntry "Will boot into Windows PE architecture " & sArchitecture & " to match OS being deployed.", LogTypeInfo
End If
If UCase(oEnvironment.Item("IsUEFI")) = "TRUE" Then
oLogging.CreateEntry "IsUEFI = TRUE", LogTypeInfo
strREDriveLetter = GetExistingRecoveryDrive
strDestFolder = strREDriveLetter & "\Recovery\WinRE"
oUtility.RunWithConsoleLogging "cmd /c MkDir " & strDestFolder
oUtility.RunWithConsoleLogging "attrib -r -h -s " & strDestFolder & "\*.*"
Else
strDestFolder = "C:\Recovery\WinRE"
End If
strSource = oEnvironment.Item("DeployRoot") & "\Boot\LiteTouchPE_" & sArchitecture & ".wim"
strDestFile = "WinRE.wim"
oLogging.CreateEntry "Installing " & strSource & " on " & sArchitecture, LogTypeInfo
oLogging.CreateEntry "Installing to " & strDestFolder & "\" & strDestFile, LogTypeInfo
If oFSO.FileExists(strDestFolder & "\" & strDestFile) Then
oLogging.CreateEntry strDestFolder & "\" & strDestFile & " already exists", LogTypeInfo
Else
oLogging.CreateEntry "oFSO.CopyFile " & strSource & "," & strDestFolder & "\" & strDestFile & ", True", LogTypeInfo
oFSO.CopyFile strSource , strDestFolder & "\" & strDestFile, True
End If
oUtility.RunWithConsoleLogging "C:\Windows\System32\ReAgentc.exe /disable"
oUtility.RunWithConsoleLogging "C:\Windows\System32\ReAgentc.exe /setreimage /path " & strDestFolder & " /target C:\Windows"
oUtility.RunWithConsoleLogging "C:\Windows\System32\ReAgentc.exe /enable"
Set colVolumes = objWMI.ExecQuery ("Select name, description from Win32_Volume")
For Each objVolume in colVolumes
oLogging.CreateEntry objVolume.Name, objVolume.Description
Next
oLogging.CreateEntry "---------------- End Run ----------------", LogTypeInfo
End Function
Function GetExistingRecoveryDrive
Dim iRetVal, oPartition, sQuery, sDriveLetter
sDriveLetter = ""
sQuery = "SELECT * from Win32_LogicalDisk WHERE DriveType = 3"
For Each oPartition in objWMI.ExecQUery(sQuery)
If InStr (oPartition.VolumeName,"Windows RE") <> 0 Then
sDriveLetter = oPartition.DeviceId
Exit For
End If
Next
oLogging.CreateEntry "assigning value " & sDriveLetter & " to Function GetExistingRecoveryDrive", LogTypeInfo
GetExistingRecoveryDrive = sDriveLetter
End Function
</script></job>