Automatically update MDT 2010 boot images in WDS


You’ve probably gone through this cycle if you are using WDS to PXE boot computers to start bare metal Lite Touch deployments:

  • Import new drivers or change bootstrap.ini.
  • “Update deployment share” to generate new WIMs.
  • Import new WIMs into WDS.

Fortunately, with the new “update” process in MDT 2010, described in more detail at http://blogs.technet.com/mniehaus/archive/2009/07/10/mdt-2010-new-feature-17-customizable-boot-image-process.aspx, it’s pretty simple to add a script to automate this process.  First, the script:

Option Explicit

Dim oShell, oEnv

Set oShell = CreateObject("WScript.Shell")
Set oEnv = oShell.Environment("PROCESS")

If oEnv("STAGE") = "ISO" then

    Dim sCmd, rc

    sCmd = "WDSUTIL /Replace-Image /Image:""Lite Touch Windows PE (" & oEnv("PLATFORM") & ")"" /ImageType:Boot /Architecture:" & oEnv("PLATFORM") & " /ReplacementImage /ImageFile:""" & oEnv("CONTENT") & "\Sources\Boot.wim"""
    WScript.Echo "About to run command: " & sCmd

    rc = oShell.Run(sCmd, 0, true)
    WScript.Echo "WDSUTIL rc = " & CStr(rc)

    WScript.Quit 1

End if

You’ll need to update the image name in the string above if you’ve changed it from the default of “Lite Touch Windows PE (x86)” and “Lite Touch Windows PE (x64)” since the script doesn’t know what you’ve changed the values to.  Save the edited script as something like “C:\Scripts\UpdateExit.vbs”.  Then, edit the “C:\Program Files\Microsoft Deployment Toolkit\Templates\LiteTouchPE.xml” file so that these lines:

<!– Exits –>
<Exits>
  <Exit>cscript.exe "%INSTALLDIR%\Samples\UpdateExit.vbs"</Exit>
</Exits>

Instead look like this:

<!– Exits –>
<Exits>
  <Exit>cscript.exe "%INSTALLDIR%\Samples\UpdateExit.vbs"</Exit>
  <Exit>cscript.exe "C:\Scripts\UpdateExit.vbs"</Exit>
</Exits>

Then make a change that requires re-generating the WIM and ISOs, e.g. change something in bootstrap.ini.  You’ll see in the “Update Deployment Share” output the generated WDSUTIL command that updates the boot image in WDS.  If WDS is located on a different server, you’ll need to update the command in the script above to add “/Server:WDSServerName” to the command.  (WDSUTIL must also be available on the machine, so you may need to install the RSAT WDS tools.)

Extra credit for someone who can convert this into a PowerShell script and look up the right boot image name 🙂


Comments (7)
  1. Anonymous says:

    Powershell and I even got the image name!  WDSUTIL doesn’t seem to mind spaces in it’s command line structure (odd but this script fails when I used quotes).  Not bad for my first crack at Powershell scripting.

    # The script:

    #——————————

    $Stage = (Get-ChildItem env:STAGE).value

    If ($Stage -eq "ISO") {

       $DeployRoot = (Get-ChildItem env:DEPLOYROOT).value

       If ($DeployRoot -like "\**") {

           $DeploymentServer = $DeployRoot.split("")[2] }

           Else {

           $DeploymentServer = (Get-ChildItem env:ComputerName).value

           }

       # Note that this script is called once for each platform image created (x86, x64)

       $Platform = (Get-ChildItem env:PLATFORM).value

       $Content = (Get-ChildItem env:CONTENT).value

       # Determine the Name of the existing .wim file that exists in the WDS Share

       $WDS_Share = "\$DeploymentServer" + (get-wmiobject win32_share -computername $DeploymentServer | where-object {$_.name -eq "REMINST"}).name

       $ImageFileName = "$WDS_ShareBoot$PlatformImages" + (dir "$WDS_ShareBoot$PlatformImages" *.wim).name

       # Grab the ‘Friendly Name’ of the WDS Image File

       $ImageName = (((wdsutil /get-imagefile /imagefile:$ImageFileName | select-string -inputobject {$_} -pattern "Image name:*").ToString()).split(":")[1]).trim()

       # Run WDSUTIL to load the image on the server being updated.

       WDSUTIL /replace-image /image:$ImageName /ImageType:Boot /Architecture:$Platform /ReplacementImage /ImageFile:$ContentLiteTouchPE_$Platform.wim /Server:$DeploymentServer

       }

    #——————————

    then adjust LiteTouchPE.xml:

    <!– Exits –>

    <Exits>

     <Exit>Powershell.exe "%deployroot%ScriptsWDSupdate.ps1"</Exit>

    </Exits>

  2. Anonymous says:

    This script worked great until I created my first remote deployment share.  When I updated the remote share’s Boot.wim, The scripts stepped up and replaced my local boot images.

    This resulted in local PXE boot.wim files that set the deployroot to the remote server share.  Worked great but, very slow of course 🙂

    I think I’ll end up disabling the extension in the LiteTouchPE.xml file on the remote share and manually replacing files on those machines.

    If I knew powershell, I think the solution would revolved around remote execution of WDSutil on the server specified in the DEPLOYROOT variable.

  3. Anonymous says:

    Hi Michael,

    I just wanted to add some additional information about this process. In fact, because there isn’t a "POSTWIM" phase it is necessary to do these automated process during "POSTISO" phase and require that "Generate a Lite Touch bootable ISO image" option have been enabled (for LiteTouch Image)

    In addition it is required to have already added these boot images in WDS manually at least one time.

    is it true ?

  4. Mehdi says:

    Hi guys,

    When i use the scirpt i have this message at the end of the update of the deploymentshare.

    About to run command: WDSUTIL /Replace-Image /Image:"Lite Touch Windows PE (x86)" /ImageType:Boot /Architecture:x86 /ReplacementImage /ImageFile:"C:UserstissirmAppDataLocalTemp32MDTUpdate.10468ISOSourcesBoot.wim" WDSUTIL rc = -1056702168  Exit code = 1

    Can you help me?

  5. Eduardo Mozart de Oliveira says:

    Thanks Micael and people that have commented so far!

    Really useful script (VBScript and PS, in comments).

    Sure I will test PS someday.

    Denver:

    I think, that another possibility, we can copy the file to a network share on the server with WDS and add the image from this share. How the file is locally at the WDS Server, the problem described should not happen.

    I did not tested this, only thinking. Maybe worth the try. Maybe someone with the same problem could test and say for us the result.

  6. showbox says:

    Thanks for the great info. I really loved this. I would like to apprentice at the same time as you amend your web site, how could i subscribe for a blog site?
    For more info on showbox please refer below sites:
    http://showboxandroids.com/showbox-apk/
    http://showboxappandroid.com/
    Latest version of Showbox App download for all android smart phones and tablets.
    http://movieboxappdownloads.com/ – It’s just 2 MB file you can easily get it on your android device without much trouble. Showbox app was well designed application for android to watch movies and TV shows, Cartoons and many more such things on your smartphone.
    For showbox on iOS (iPhone/iPad), please read below articles:
    http://showboxappk.com/showbox-for-ipad-download/
    http://showboxappk.com/showbox-for-iphone/
    Showbox for PC articles:
    http://showboxandroids.com/showbox-for-pc/
    http://showboxappandroid.com/showbox-for-pc-download/
    http://showboxforpcs.com/
    There are countless for PC clients as it is essentially easy to understand, simple to introduce, gives continuous administration, effectively reasonable. it is accessible at completely free of expense i.e., there will be no establishment charges and after establishment
    it doesn’t charge cash for watching films and recordings. Not simply watching, it likewise offers alternative to download recordings and motion pictures. The accompanying are the strides that are to be taken after to introduce Showbox application on Android.
    The above all else thing to be done is, go to the Security Settings on your Android telephone, Scroll down and tap on ‘Obscure sources’.

  7. aw says:

    hai, I just want to tell you that I am just very new to blogs and seriously loved this website. More than likely I’m planning to bookmark your blog post .
    You amazingly come with really good posts. Thanks a lot for sharing your blog Microsoft.

    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Aceh
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bali
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Balikpapan
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bandung
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Banjarmasin
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Banten
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Batam
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bekasi
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bengkulu
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bogor
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Bontang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cianjur
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cikarang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cilegon
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Cirebon
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Denpasar
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Jakarta
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Jambi
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Jember
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Karawang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Kendal
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Kudus
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Kupang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Lampung
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Madiun
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Makasar
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Malang
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Maluku
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Manado
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Medan
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20NTT
    http://www.lokerjobindo.com/search/label/Loker%20Daerah%20Padang

Comments are closed.