Ben Hunter

Architect - Microsoft Enterprise Services - Redmond

BDD 2007 - Tips and Tricks - Integrating WinRE into Vista with BDD

BDD 2007 - Tips and Tricks - Integrating WinRE into Vista with BDD

  • Comments 11
  • Likes

Windows Recovery Environment (Windows RE) is a recovery platform based on Windows Preinstallation Environment (Windows PE). Windows RE provides two main functionalities, Automatic diagnosis and repair of boot problems using a tool called Startup Repair and a centralized platform for advanced recovery tools.
based on this functionality I think it makes a lot of sense to integrate WinRE into all of your Vista deployments. From the number of questions I have received on the topic it seems like I am not the only one!

So how do we integrate WinRE into the Vista deployment process using BDD 2007?

The first thing I do is I create my WinRE source. There is a good article on the WinRE team blog that explains how to create a WinRE source using the WAIK. Unfortunately adding the Mass storage and network drivers for all the models you want to support can be quite laborious. The obvious question here is “why can’t we just use the BDD driver library?” to do this for us, after all it is used to create the Lite touch WIM. Well thanks to Dave Hornbaker a fellow Microsoft Services consultant you can.

Dave has developed a PowerShell script that automatically creates a WinRE WIM and then injects the drivers that you have already imported into BDD, NICE!

The script must be run on a machine with both BDD and the WAIK installed. The script is attached to this blog and is usage is detailed below:

Powershell .\CreateWinRE.ps1 [Arch] [Group] [–ISO] [–MassStorageDrivers] [–Net] [–system] [–Display]
     Arch - “x86” or “x64” (“x64” has not been tested) Default is “x86”
     Group - BDD Driver group name. Driver group to be injected into the image. Default is “All Drivers”
     -ISO - Create an ISO image Default is to just create a WIM
     -MassStorageDrivers - Inject Mass Storage Drivers (default)
     -Net - Inject network drivers (default)
     -System - Inject system drivers
     -Display - Inject display drivers

Now we have this fantastic script, run it to create the WinRE WIM the and inject the drivers as required:

Powershell .\CreateWinRE.ps1 –MassStorageDrivers –Net

Now that we have out WIM we can integrate into the BDD deployment process:

Copy the following files to the specified locations:

  1. Copy SetAutoFailover.cmd to the distribution\scripts folder and rename it to Z-SetAutoFailover.cmd - This script is provided by the Windows AIK - under: C:\Program Files\Windows AIK\Recovery.
  2. Copy the script Z-INSTALL-WinRE.wsf to the distribution\scripts folder – Attached to this blog

Now create an application with the following settings:

  1. Open the Deployment Workbench
  2. Right click on Distribution Share \ Applications and click New
  3. Select Application without source files or elsewhere on the network and click Next
  4. Set Application Name to INSTALL-WinRE and click Next
  5. Set the Command Line to cscript "%SCRIPTROOT%\Z-INSTALL-WinRE.wsf"
  6. Set the Working Directory to %SCRIPTROOT% and click Add

Next add the application to task scheduler, it is important to note that you should add this to your deployment build not your master image as WinRE will be disabled by sysprep :

  1. Open the Deployment Workbench
  2. Right click on Builds \ <Build ID> and click Properties
  3. Select the Task Sequence tab
  4. Navigate to the State Restore group
  5. Select the Enable Bitlocker task
  6. Click the Add button and select Application \ INSTALL-WinRE
  7. Click Ok to confirm

NOTE: <Build ID> is the name of the build to edit i.e. DEPLOY-VISTA

The sample script I have provided simply copies the WinRE.wim file to the C drive and enables WinRE. You may want to look at other options such as locating it on a partition with Bitlocker or creating a seperate partition just for WinRE. For more information about the possible configuration options please refer to the WinRE team blog.

Disclaimer: The information on this site is provided "AS IS" with no warranties, confers no rights, and is not supported by the authors or Microsoft Corporation. Use of included script samples are subject to the terms specified in the Terms of Use.

Attachment: Ben Hunter - WinRE files.zip
Comments
  • PingBack from http://desktopfeedbag.wordpress.com/2007/05/22/integrating-winre-into-vista-with-bdd/

  • This powershell script rocks! I am going to incorporate this into my BDD installs along with the ability to build WinRE onto a hidden partition into all of my Windows Vista builds.

  • Ok,  I suppose I am missing something obvious, I am early in my Powershell knowledge curve, so I just don't have the skills to debug this yet.  Anyway every time I run this I get errors.  Perhaps it assuming something that isn't true about my machine? For example bdd 2007 is installed on the d: and not c: while the wiak is on c:...

  • Hi Bill,

    Can you post the errors here then I should be able to help you.

    Thanks,

    Ben

  • Bill, you will likely need to change the security rights within powershell.

    How would you go about modifying this script to install WinRE onto a hidden partition?  So far I've not been sucessfull at it via my BDD deployments.

  • Hi Stefan,

    I have not tried to install it on a hidden partition. One suggestion I would have is to install it on a artition that is not hidden then hide the partition once you have installed WinRE. I beleive that thetre is some good information on this on the WinRe team blog.

    Thanks,

    Ben

  • Ben,

    How would I change the script over to apply WinRe to a Bitlocker partition?

  • I'm using the latest version of Microsoft Deloylment...  the script errors out in a few different places.  I modified the path to reference "\Microsoft Deployemtn Toolkit\" instead of "\BDD 2007\" but it errors creating the wim.  Specificially:

    Exception calling "Run" with "2" argument(s): "The image file %1 is valid, but is for a machine type other than the cur

    rent machine"

    At F:\Distribution\CreateWinRE-MDS.ps1:109 char:24

    + $Result = $Manager::Run( <<<< $Imagex, "/export /boot """ + $BootWim + """ 2 " + $tmpWinRE + " ""Windows Recovery Env

    ironment""")

    You cannot call a method on a null-valued expression.

    At F:\Distribution\CreateWinRE-MDS.ps1:110 char:43

    + Write-Debug ("Result: " + $Result.ToString( <<<< ))

    You cannot call a method on a null-valued expression.

    At F:\Distribution\CreateWinRE-MDS.ps1:111 char:98

    + if ($Result -ne 0){Write-Host ("Unable to create WinRE WIM file: Result was: " + $Result.ToString( <<<< ));Exit $Resu

    lt}

  • Hi Johnnie,

    Unfortunately I have not had a chance to test this with MDT. It may be a while before I get a chance. If you do find a solution then please post a comment.

    Thanks,

    Ben

  • I have always had trouble with the script picking up the location of my BDD (now MDT) install.

    I typically just change line that tells it where to find the tool...

    so...

    $x = [Reflection.Assembly]::LoadFile($env:ProgramFiles + "\Bdd 2007\bin\Microsoft.BDD.ConfigManager.dll")

    becomes...

    $x = [Reflection.Assembly]::LoadFile("d:\program files" + "\Microsoft Deployment Toolkit\bin\Microsoft.BDD.ConfigManager.dll")

    Specifically spelling out the location of the Tool since I keep it on the d: drive...probably the right thing to do would be Param the location defaulting to C:, but over riding if its specified.

    I usually just change the targeted arch at the top of the script too since I am in there.

    I just ran it with MDT 2008 and WAIK 1.1 and it seems to work.

  • If you are new to Powershell (like me) and need some help enabling Powershell scripting support check this site:

    http://www.tech-recipes.com/rx/2513/powershell_enable_script_support

    Script ran fine after I followed the easy instructions and I now have a nice WinRE.wim

    Thanks to Ben and Dave for their efforts! ;-)