# Monday, June 29, 2009

The process of creating a Windows PE 3.0 disk has changed slightly from the previous version. Luckily the Windows PE User’s Guide that ships with the WAIK has all the information you’ll ever need. To get started download the WAIK for Windows 7 RC here. Then follow the steps in the section “Windows PE Walkthroughs”. I’ve provided the batch file I use to create a generic WinPE 3.0 ISO below.

@Echo off"
REM ********************************************************************************
REM head block

REM Setup
SET PETOOLS=C:\Program Files\Windows AIK\Tools\PETools
SET ARCH=x86
SET WORKINGDIR=%~dp0windowspe-%ARCH%


IF NOT EXIST "%WORKINGDIR%" Goto :COPYPE
Echo "%WORKINGDIR%" exists, Removing....
rmdir "%WORKINGDIR%" /S /Q


:COPYPE
cd /d "%PETOOLS%"

call copype.cmd %ARCH% "%WORKINGDIR%"

REM Copy Base WIM to boot.wim
copy "%WORKINGDIR%\winpe.wim" "%WORKINGDIR%\ISO\sources\boot.wim"

REM Mount boot.wim
Dism /Mount-Wim /WimFile:"%WORKINGDIR%\ISO\sources\boot.wim" /index:1 /MountDir:"%WORKINGDIR%\mount"

REM Add Optional Components
Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\winpe-wmi.cab"
Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\en-us\winpe-wmi_en-us.cab"

Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\winpe-hta.cab"
Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\en-us\winpe-hta_en-us.cab"

Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\winpe-mdac.cab"
Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\en-us\winpe-mdac_en-us.cab"

Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\winpe-scripting.cab"
Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\en-us\winpe-scripting_en-us.cab"

Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\winpe-wmi.cab"
Dism /image:"%WORKINGDIR%\mount" /Add-Package /PackagePath:"%PETOOLS%\%ARCH%\WinPE_FPs\en-us\winpe-wmi_en-us.cab"

REM Copy Imagex into the Windows Dir
copy "C:\Program Files\Windows AIK\Tools\%ARCH%\imagex.exe" "%WORKINGDIR%\mount\Windows"

REM COpy Tools
xcopy %~dp0Tools %WORKINGDIR%\ISO /E /S

REM Unmount the WIM
Dism /unmount-Wim /MountDir:"%WORKINGDIR%\mount" /Commit


REM Create the ISO
oscdimg -n -b"%WORKINGDIR%\etfsboot.com" "%WORKINGDIR%\ISO" "%WORKINGDIR%\winpe_x86.iso"

You may want to comment out the line with “xcopy %~dp0Tools” at the beginning. I usually copy a bunch of tools onto my WinPE disk using this tools directory.

posted on Monday, June 29, 2009 2:14:16 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]
# Tuesday, December 16, 2008

When working with the Microsoft Deployment Toolkit (MDT) I spend a lot of time in VMWare Workstation as it makes the job of developing and testing a workstation image much simpler. However there is one big gottcha that you should be aware of. Make sure you edit your .VMX file and modify the following:

scsi0.present = "TRUE" should be changed to scsi0.present = "FALSE"

If you don't do this then after deploying a Syspreped image to VMWare Workstation you'll end up with a Stop 0x7B error and much less hair than when you started.

Thanks Chris for reminding me of something I supposedly knew. :)

posted on Tuesday, December 16, 2008 3:20:49 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]
# Thursday, October 16, 2008

The answer is yes! Incidentally, is there really any limit to what you can do with ConfigMgr?? Well I suppose that is like asking, "How much wood could a woodchuck chuck if a woodchuck could chuck wood?", but anyway let's move on.

My first clue for solving this came from deployvista.com, "Using the $OEM$ folder with SCCM 2007 OS Deployments". To summarize you need to place your $OEM$ files into C:\_SMSTaskSequence\OSD\$OEM$ in order for Windows Setup to use the files. Here is what I did:

  1. Added my $OEM$ Files to my MDT Settings Package. (The one with unattend.txt, sysprep.inf and customsettings.ini)
  2. Add Z-CONFIG-CopyOEM.wsf to your MDT Source Files package. I've provided it below. (Remember to update DP)
  3. In your Task Sequence right before "Setup Windows and ConfigMgr" add a new "Run Command Line" task.
  4. Set the Name to "Copy OEM Files".
  5. Set the Command Line to "cscript.exe "%deployroot%\scripts\Z-CONFIG-CopyOEM.wsf".
  6. Click the "Package" checkbox and select your MDT Settings Package.
  7. All Done!

The guts of the script is pretty simple stuff and it works because when you set a Package in a Run Command Line Task the current directory is the path to whatever package you've select. In this case the current directory is the MDT Settings package containing our $OEM$ files.

'//----------------------------------------------------------------------------
'//  See if we can find the $OEM$ Directory
'//----------------------------------------------------------------------------
sDest = OEnvironment.GetOSDV4("_SMSTSMDATAPATH") & "\OSD\$OEM$"
oLogging.CreateEntry "$OEM$ Files will be copied to " & sDest, LogTypeInfo 

'//----------------------------------------------------------------------------
'//  Make sure the Destination exists
'//----------------------------------------------------------------------------
MKDir sDest 

'//----------------------------------------------------------------------------
'//  Get the Source Location and Copy the files
'//----------------------------------------------------------------------------
sSource = oShell.CurrentDirectory & "\$OEM$"
oLogging.CreateEntry "$OEM$ Files will be copied from " & sSource, LogTypeInfo 

'Copy the folder
oFSO.CopyFolder sSource, sDest 

posted on Thursday, October 16, 2008 3:30:23 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]
# Thursday, October 02, 2008

Today I was attempting to create a sysprep.xml file for Windows 2008. After opening my WIM file in Windows SIM I got the prompt to generate a Catalog file, clicked Yes and then......Error!! What?? Lets try that again....Error!! Whatever, lets try again, Error!! Ok this time I read the error. "System.Reflection.TargetParameterCountException: Parameter count mismatch." Ummm, what??

After wasting almost 2 hours chasing this error I found this post on the TechNet Forums: http://forums.microsoft.com/TechNet/ShowPost.aspx?PostID=3066853&SiteID=17.

The key information is:

Because of the changes in the servicing stack in Windows Vista with Service Pack 1 (SP1) and Windows Server 2008, Windows System Image Manager (Windows SIM) cannot create catalog files for some Windows images of different architecture types. The following list describes the Image Manager architecture types and catalogs that can be created for each one.

x86 Windows SIM:
Can create catalogs for x86, x64, and Itanium-based Windows images.

x64 Windows SIM:
Can create catalogs only for x64 Windows images.

Itanium-based Windows SIM:
Can create catalogs only for Itanium-based Windows images. 

Please confirm if what version of Windows SIM you are using. I recommend installing x86 Windows SIM.

Hope it helps.

Tim Quan - MSFT

Update: Michael Niehaus pointed out that this information is available in the updated version of the WAIK 1.1 release notes available at http://www.microsoft.com/downloads/details.aspx?FamilyID=051091e8-51ea-4d2c-96b3-dc9863edebd9&displaylang=en.

posted on Thursday, October 02, 2008 11:12:33 AM (E. Australia Standard Time, UTC+10:00)  #    Comments [3]
# Sunday, June 22, 2008

I'm not sure how I missed this one or how long it has been available but you can download the source code for MDT 2008 from Microsoft Download. You can learn a lot about how MDT 2008 works and also a lot about managed MMC snap-ins from the MDT 2008 source code. Click here to download.

posted on Sunday, June 22, 2008 10:18:04 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]
# Tuesday, June 17, 2008

I spotted an article on Micheal Niehaus' blog the other day about moving to a single partition when doing OS deployments. You can read the article here.

This very issue arose in the project I am currently involved in and after trying reading and implementing Micheal's post I found a couple of nuances:

  • If there is an OEM partition (like WinRE) then you risk deleting you're OS partition. OEM partitions are often a hidden partition (Type 0x27) at the start of the disk that allow OEM's to offer a recovery environment for their customers.
  • If there is more than a one extra partition on the disk then ExtendOemPartition=1 won't really work.

I thought the problem deserved some more attention so I've written a script to be included in the "Refresh only" section of "Preinstall" in the Task Sequence that you use to deploy you're image. The script queries WMI to find how many partition are on the disk that contains C:. If there are any partitions after the C: partition they are removed using diskpart "delete partition".

Any comments or suggestions please let me know!

posted on Tuesday, June 17, 2008 2:26:12 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]
# Wednesday, May 28, 2008

So once you've created a Distribution share with MDT at some point you're going to need a LAB Deployment point. Creating and updating Deployment Points is managed via [Microsoft.BDD.ConfigManager.Manager] in Microsoft.BDD.ConfigManager.dll.

To get stared you need need a DeployManager:
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft Deployment Toolkit\Bin\Microsoft.BDD.ConfigManager.dll") | Out-Null
$manager = [Microsoft.BDD.ConfigManager.Manager]
$deployManager = $manager::DeployManager

Once you've got a DeployManager you can create a new deployment point using CreateNew(). This returns a generic deployment point which you can then specify what type and settings you need for the deployment point. Specifying the type and settings (ie. all the options on the General, Rules, WinPE tabs) is done by setting some properties on the deployment point object like so:

$deploymentPoint = $deployManager.CreateNew()
$deploymentPoint["Name"] = "LAB"
$deploymentPoint["Type"] = "LAB"
$deploymentPoint["NetworkShare"] = $NetworkShare
$deploymentPoint
["LocalSharePath"] = $LocalSharePath
$deploymentPoint
["GenerateLiteTouchISO"] = $true
$deploymentPoint["GenerateLiteTouchFlatISO"] = $false
$deploymentPoint["GenerateGenericISO"] = $false
$deploymentPoint["GenerateGenericFlatISO"] = $false

This is not a complete list of properties but it gives you the right idea. Once you have a deployment point you also need to specify which Applications, Task Sequences and Driver Groups you wish to include. For a LAB deployment point this is all of them:

$applicationRow = $deploymentPoint.CreateNewChild("Application")
$applicationRow["Application_Column"] = "*"
$deploymentPoint.AppendChild("Application", $applicationRow)

$taskSequenceRow = $deploymentPoint.CreateNewChild("TaskSequence")
$taskSequenceRow["TaskSequence_Column"] = "*"
$deploymentPoint.AppendChild("TaskSequence", $taskSequenceRow)

$driverGroupRow = $deploymentPoint.CreateNewChild("DriverGroup")
$driverGroupRow["DriverGroup_Column"] = "*"
$deploymentPoint.AppendChild("DriverGroup", $driverGroupRow)

After we've made all the changes we want you need to commit all the changes:
$deploymentPoint.Update()

The other really nice part about using MDT from powershell is the Bootstrap and CustomSettings writers that are built in. For example, if I want to add some lines to Bootstrap and CustomSettings.ini for the deployment point I've just created:

#Update the Bootstrap.ini file
$deploymentPoint.Bootstrap.Write("Default", "DeployRoot", $NetworkShare)
$deploymentPoint
.Bootstrap.Write("Default", "KeyboardLocale", "en-AU")
$deploymentPoint
.Bootstrap.Write("Default", "SkipBDDWelcome", "YES")

#Write Some default values to the CustomSettings.ini file
$csIni = $deploymentPoint.CustomSettings
$csIni.Write("Default", "_SMSTSORGNAME", "Windows XP Build Process")
$csIni.Write("Default", "UserDomain", "LAB")
$csIni.Write("Default", "KeyboardLocale", "en-AU")
$csIni.Write("Default", "SkipBDDWelcome", "YES")

For an end-to-end example have a look at Create-LABDeploymentPoint.zip (1.4 KB). This script sets up a lab deployment point and sets a bunch of settings that I use for XP deployments. If you want to test it out without breaking your existing LAB deployment point change line 23 to LAB_TEST.

posted on Wednesday, May 28, 2008 10:48:43 AM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]
# Tuesday, April 29, 2008

I've been playing with automating MDT 2008 using Powershell and thought I'd start to share some of the info over the next few weeks.

The very first thing you need to do in MDT is create a Distribution Share. It turns out this is exceptionally easy in Powershell. The Microsoft.BDD.ConfigManager.Manager namespace has a method called UpgradeDistributionShare(string location, bool update). Just pass in the location you'd like to create the distribution share at and you're done! You can set update to true if you are upgrading an existing Distribution Share to MDT 2008.

Here is the code:

Param
(
   [
string]$Location =$(throw "You must specify a Location")
)

#Initialize MDT
[System.Reflection.Assembly]::LoadFile("C:\Program Files\Microsoft Deployment Toolkit\Bin\Microsoft.BDD.ConfigManager.dll") | Out-Null
$manager = [Microsoft.BDD.ConfigManager.Manager]

#Create a new MDT Distribution Share
$manager::UpgradeDistributionShare($Location, $false)

posted on Tuesday, April 29, 2008 1:36:55 PM (E. Australia Standard Time, UTC+10:00)  #    Comments [0]